You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by marnold <ma...@gmail.com> on 2012/01/25 17:59:41 UTC

Camel route JMS -> SOAP -> JMS

Hi,

I am trying to create a Camel route that will:

1) get JMS messages from a queue (using ActiveMQ),
2) send the message to a third-party SOAP web service,
3) take the response from that web service and,
4) put it onto another JMS queue

In addition, I'd like to populate the JMS correlation ID on the JMS message
queued at 4. with the JMS message ID of the message dequeued at 1.

This is my attempt:



What I find is that the JMS correlation ID is set correctly, but the body of
the JMS message is null.  When I set tracing on my Camel context I find I
get a BodyType:org.apache.camel.component.cxf.CxfPayload and a correctly
populated Body, but on the JMS enqueue I get BodyType:null, Body:[Body is
null].

Why is the body lost?  Is it because I am setting the header?  Please let me
know if I'm going about this in the wrong way or have made a fundamentally
incorrect assumption on the way Camel works.

Camel 2.9.0, ActiveMQ 5.5.1.

Thanks!





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5430745.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route JMS -> SOAP -> JMS

Posted by marnold <ma...@gmail.com>.
Thanks Babak.

I had assumed Camel would auto-magically create a JMS TextMessage with the
message text from the body of the Camel message, and JMS StringProperties
from the Camel message's headers.

I will look into your suggestions.

Thanks again.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5435834.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route JMS -> SOAP -> JMS

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

In the future we most likely should remove the setOutXXX in the DSL as
they are not usable and adds to the confusion.
People should generally just use setBody / setHeader / transform, and
the Camel DSL figures it out.



On Mon, Jan 30, 2012 at 2:17 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi,
>
> setOutHeader doesn't copy the message body, you'd better use the setHeader
> to that kind of job.
>
>
> On Mon Jan 30 20:59:18 2012, marnold wrote:
>>
>> I played around with custom TypeConverters with no luck.  I couldn't
>> understand the messageConverter documentation and wanted to avoid all
>> things
>> Spring.
>>
>> On a whim I removed the<setOutHeader>  and found I was right in that the
>> payload is automatically converted to the JMS message body.  For some
>> reason
>> the presence of the<setOutHeader>  clears the message body.  If I use
>> <setHeader>  (rather than<setOutHeader>), I retain the message body and
>> have
>> the JMSCorrelationID set appropriately.
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5441339.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>        http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang Weibo: willemjiang



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Camel route JMS -> SOAP -> JMS

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

I don't know much about CXF however I intend to understand how it worked at
all *without* any explicit type conversion as I've already recommended by
this thread.
The CxfProducer is invoked in the PAYLOAD mode, that's (if I'm not wrong)
the Body of the Out Message populated into the Camel Exchange will be of the
type List<javax.xml.transform.Source>. However the JMS documentation,
Paragragh "Message Mapping between JMS and Camel":

http://camel.apache.org/jms

doesn't mention that we have an automatic type conversion for that as well!

So what do I exactly miss here?

Babak


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5441522.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route JMS -> SOAP -> JMS

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

setOutHeader doesn't copy the message body, you'd better use the 
setHeader to that kind of job.

On Mon Jan 30 20:59:18 2012, marnold wrote:
> I played around with custom TypeConverters with no luck.  I couldn't
> understand the messageConverter documentation and wanted to avoid all things
> Spring.
>
> On a whim I removed the<setOutHeader>  and found I was right in that the
> payload is automatically converted to the JMS message body.  For some reason
> the presence of the<setOutHeader>  clears the message body.  If I use
> <setHeader>  (rather than<setOutHeader>), I retain the message body and have
> the JMSCorrelationID set appropriately.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5441339.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Camel route JMS -> SOAP -> JMS

Posted by marnold <ma...@gmail.com>.
I played around with custom TypeConverters with no luck.  I couldn't
understand the messageConverter documentation and wanted to avoid all things
Spring.

On a whim I removed the <setOutHeader> and found I was right in that the
payload is automatically converted to the JMS message body.  For some reason
the presence of the <setOutHeader> clears the message body.  If I use
<setHeader> (rather than <setOutHeader>), I retain the message body and have
the JMSCorrelationID set appropriately.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5441339.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route JMS -> SOAP -> JMS

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi,

you can't put anything other than a javax.jms.Message Object into a JMS
Queue, so that you should convert your received SOAP Payload to that before
producing messages into the Queue.

There're many ways to achieve this some of them are:

- Make use of your own custom TypeConverter [1]
- Use Bean-Binding [2] which invokes your POJO method for the conversion
- Spring messageConverter [3] option of the JMS Endpoint

[1] http://camel.apache.org/type-converter.html
[2] http://camel.apache.org/bean-binding.html
[3] http://camel.apache.org/jms

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-JMS-SOAP-JMS-tp5430745p5430875.html
Sent from the Camel - Users mailing list archive at Nabble.com.