camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen">
Subject RE: Bridging the ActiveMQ with IBM Websphere using Camel
Date Wed, 24 Sep 2008 09:02:39 GMT
Ad 1)
Missing payload. Sounds as if when you do get the payload and print it using system out, the
payload type is stream based and thus can ONLY be read once.

I do believe that we have added some stream cache features into Camel so you can read it more
than ONCE. 

Ad 2)
Yeah Camel has an internal representation of JmsMessage as you wrote.
There is a getJmsMessage() to get the javax.jms.Message object. 

The getBody() method should return the payload with the appropriate type such as String.

Sending the message to IBM MQ)
Looks like you can use the option alwaysCopy=true and then you can create the javax.jms.JmsMessage
object to send wrapped in an org.apache.camel.component.jms.JMSMessage object. Then you are
in control and Camel should not interfere and filter out headers etc.

The option is configured on the uri:

And in your processor java code, something like this:

Javax.jms.Message myJavaxJmsMessage = ...
// here get a standard JMS message and set the payload and the properties to send

// wrap it into a camel message and set the body to send
exchange.getIn().setBody(new org.apache.camel.component.jms.JMSMessage(myJavaxJmsMessage));

This is just what I could find looking into the source for 5 mins.

Med venlig hilsen
Claus Ibsen
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576

-----Original Message-----
From: JavaRat [] 
Sent: 24. september 2008 09:17
Subject: RE: Bridging the ActiveMQ with IBM Websphere using Camel

Thank you for your reply once again Claus!

We have been researching the pointers you gave us.
After some experimenting we found a few interesting things with camel. This
is what we think is happening in camel and our problem (we attach another
sketchy picture what we think is happening):


Question: The payload is missing on the message put onto the final

Probable cause: While trying out the with the following
code we left an old fashion system.println.out in the code:
from( Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("camelInMsg = " +exchange.getIn().toString());

We belive by doing exchange.getIn() you actually take the message "off the
queue" and if not setting the exchange.setIn() afterwards you will end up
with an empty message? (Removing the system.out.println and you get your
original message on the finalqueue as we want)


Question: When picking a message off the Active MQ queue it seems that Camel
"wraps it in an own "Messagewrapper" called
How will we reach the "real message we need to access and enrich?"?!

What we have tried:
We attempt too dig into the original message by peeling off the
camelshellmessage using some cast like:
JMSMessage camelWrapMessage =  (JMSMessage)exchange.getIn();
ActiveMQTextMessage myInnerTextMessage =

Now the original message seems to be accessable for adding additional
information as in our case were we want to put a few IBMMQ specific
properties such as for example
myInnerTextMessage.setStringProperty(JMS_IBM_Format", MQC.MQFMT_STRING); and 
However here is an interesting feature when we use
myInnerTextMessage.setStringProperty("jms_IBM_Format", MQC.MQFMT_STRING);
camel will not think it is a specific JMS property and accept it as a custom
header. (So be mindful when using capital letters.)

After this is done we can now what we believe is the actual message put onto
the next queue with first camelWrapMessage.setJMSMessage(myInnerTextMsg);

So far so good...

However when we check the IBM MQ queue we find the message properties are
set what looks like a textmessage inside a JMSmessage ?!
Why do we have this at the end?

We are guessing here and this is where really could use some help:

We want ONLY the textMessage to be sent not the camelWrapMessage, this might
not be our problem though since we use:

<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="">
<property name="transportType">
<util:constant static-field=""/> 
<property name="queueManager" value="QMgr"/>
<property name="hostName" value=""/>     
<property name="port" value="1414"/>

in our camel-context.xml. But if we remove the 

<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">



we cannot seem to get it too connect to our IBM MQ queue?

Question 3: How do we remove what looks like the extra enwrapped JMSMessage
and only send our original TextMessage to the final queue?

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message