camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
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:
from(xxX).to("ibmmq:queue:xxx?alwaysCopy=true");

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
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: JavaRat [mailto:fredrik.sassenberg@mindwell.se] 
Sent: 24. september 2008 09:17
To: camel-user@activemq.apache.org
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):

http://www.nabble.com/file/p19643280/camelencapsulation.jpeg
camelencapsulation.jpeg 

1.

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

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

    
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)


2.

Question: When picking a message off the Active MQ queue it seems that Camel
"wraps it in an own "Messagewrapper" called
org.apache.camel.component.jms.JMSMessage.
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 =
(ActiveMQTextMessage)camelWrapMessage;

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 
myInnerTextMessage.JMSReplyTo(responseQueue);
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);
exchange.setIn(camelWrapMessage);

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="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ"/> 
</property>
<property name="queueManager" value="QMgr"/>
<property name="hostName" value="xxx.xxx.xxx.xxx"/>     
<property name="port" value="1414"/>
</bean>
</property> 
</bean>

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

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

...

</property> 
</bean>

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: http://www.nabble.com/Bridging-the-ActiveMQ-with-IBM-Websphere-using-Camel-tp19623329s22882p19643280.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message