3 Replies Latest reply on Oct 6, 2008 3:15 AM by davinci25

    Bridging the ActiveMQ with IBM Websphere using Camel

    davinci25 Newbie

      The trend seem too be moving towards using the camel component in Servicemix version 4 and also as a standalone routingcomponent therefore we attempt to use it in our coming projects. However while trying to bridge an ActiveMQqueue with an IBM MQ websphere queue we have discovered the following problem (please see attached picture).


      Messages taken off the Active MQ queue and delivered onto the IBM MQ Websphere queue which is good and what we want. However the messages will not have the specific parameters set in the JMS header and it?s payload emptied???


      Hopefully this is an error from our part but without success we have tried to locate the faulty code and are now turning too this forum for any advice or pointers where we are going wrong. (It might be worth mentioning that this code has worked for us previously using the Servicemix-JMS-Component which we have tried adapting in the camel approach.)


      Our setup is as follows:






      public class MyRouteBuilder extends RouteBuilder {


      public void configure() {

      from("activemq:queue.in").process(new Processor() {

      public void process(Exchange exchange) throws Exception {

      JmsMessage inMsg = null;


      if (exchange.getIn() instanceof JmsMessage) {

      inMsg = (JmsMessage)exchange.getIn();

      javax.jms.Message inMsgMsg = inMsg.getJmsMessage();


      if (inMsgMsg instanceof ActiveMQTextMessage) {

      ActiveMQTextMessage inTextMsg = (ActiveMQTextMessage)inMsgMsg;


      inMsgMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_STRING);

      inMsgMsg.setIntProperty("JMS_IBM_MsgType", MQC.MQMT_REQUEST);


      else {

      System.out.println("inMsgMsg not a ActiveMQTextMessage but a " + inMsgMsg.getClass().toString());




      else {

      System.out.println("inMsg not a JmsMessage but a " + exchange.getIn().getClass().toString());









      A search through forums provided some related clues what might be a problem in this case???







        • 1. Re: Bridging the ActiveMQ with IBM Websphere using Camel
          Adrian Trenaman Newbie

          Hi there,


          I took a look at this problem using Camel Camel attempts to do a few things when it propagates headers: first, it attempts to ensure that the header is a valid Java identifier (or at least, can be converted to a valid Java identifier by replacing periods ('.') with underscores ('_')). Second, and interesting in your case, it applys special rules to properties beginning with JMS. Take a look at JmsBinding.java in package org.apache.camel.component.jms. In the method "appendJmsProperty" you'll see the special processing that takes place.


          You custom property 'JMS_IBM_Format' begins with 'JMS', and so is being ignored as it's not one of the standard JMS properties.


          Can you change the name of your property (say, to use a lowercase 'jms') and test again?

          • 2. Re: Bridging the ActiveMQ with IBM Websphere using Camel
            davinci25 Newbie

            Changing JMS_IBM_Format too jms_IBM_Format works nicely thank you Ade. However it seems that the "innerTextMessage" is not put onto the final queue.out destination  but instead is wrapped inside a JMSMessage?!


            This is what we are guessing is happening:




            Is the outside org.apache.camel.component.jms.JmsComponent enwrapping our TextMessage?

            We believe we are sending our TextMessage inside a JMSMessage to the final queue because when browsing the queue we find the properties we set above but not on the message that the IBM MQ queue is receive but inside! (Please view the attached picture to see what we believe is happening)


            Can we somehow avoid sending a message inside a message to IBM MQ?

            • 3. Re: Bridging the ActiveMQ with IBM Websphere using Camel
              davinci25 Newbie

              Letting things sink in a bit and answering my own question here I think I understand a little more about what is going on here.


              What I am trying to do is sending a JMS Message to an IBM MQ Queue. IBM MQ Queue are default not expecting a JMS message and therefore you need to let "it know" that you intend to put a JMS Message onto the queue and it should look for the JMSset of properties in the message.


              What we need here is a way to let the queue know this and in camel (fuse mediation router) it is not possible (from what I understand) to put the property setTargetClient=1 as we are able to do in the case of Servicemix-JMS. In servicemix-jms the answer was easy as we could just put this property into the URI like this:





              Should work in spring too solve this. Hopes this might help anyone out there facing the same problem. If you should find a solution please send me a message or post here!