Home » Camel » Running Apache Camel in OpenESB – Part 2

Running Apache Camel in OpenESB – Part 2

In my previous post, I gave a step by step guide on running your first camel application in OpenESB. This entry is continuation to that it shows how to invoke an outbound JBI call from Camel. We will modify the same application to send message to a Glassfish’s JMS Queue instead of ActiveMQ’s queue.

1. To send a message to Glassfish’s Queue, we need a create JMS Binding WSDL

Create a WSDL using the Wizard and select JMS Binding. Follow the wizard to provide a queue name, access details, etc. The WSDL should be created in CamelCompAppJBIModule1 project in default package. Choose the jbi2camel.xsd and select input element as msg:AnyMessage.

Below is the types part and message part from the wsdl:

  <xsd:schema targetNamespace="http://openesb.org/jbi2camel/CamelJBIModule1">
    <xsd:import schemaLocation="jbi2camel.xsd" namespace="http://openesb.org/jbi2camel/message/CamelJBIModule1"/>
<message name="JMSInputMessage">
  <part name="part1" element="msg:AnyMessag"/>

2. Edit the jbi.xml in CamelCompAppJBIModule1 project to add the consumes element:

<consumes service-name="JMSOutService" 
   interface-name="jms:JMSOutPortType" >

Make sure the service-name, endpoint-name, interface-name are the same ones from the newly created JMS wsdl.

3.  Edit the AppRouteBuilder.java as below:


public void configure() {

     String jbiJMSTestQueue = "jbi:http://j2ee.netbeans.org/wsdl/CamelJBIModule1/src/jmsTestQueue/JMSOutService/jmsTestQueue_OutPort"; //(A)
     String jbiURI = "jbi:http://openesb.org/jbi2camel/CamelJBIModule1/CamelJBIModule1_service/jbi2camel_endpoint"; //(B)
     from(jbiURI).process(new Processor() { //(C)
     public void process(Exchange exchng) throws Exception {
       Message inMessage = exchng.getIn();
       String strInMsg = inMessage.getBody(String.class);
       System.out.println("Received in Processor : " + strInMsg);

       String strOutMsg = strInMsg.replace("My String", "MyReply");
       exchng.getOut().setBody(strOutMsg); // (D)

    }}).to(jbiJMSTestQueue); //(E)

A) The variable “jbiJMSTestQueue” refers to the JMS WSDL’s endpoint. This URL is constructed by concatenating namespace, service name, port name.
E). This line sends the message to the new JMS Queue.

4) Right click on Service Assembly node and “Clean” it. A dialog box will ask for confirmation. Say Yes.



5) Your CASA should now look like this:

2-26) Drag the soap icon from wsdl bindings and add it to “WSDL Ports” pane. Then drag the endpoint from SOAP icon to CamelJBIModule1 as shown below:


7) Build and deploy the project.

8) Run the test case to make sure that it succeeds.






Leave a Reply

Your email address will not be published. Required fields are marked *