camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uprooter <uproo...@gmail.com>
Subject Re: Why does my JMS message type changes ?
Date Mon, 18 May 2009 08:53:33 GMT

Many thanks to your both.
If I understand correctly, I need to set a header on my message and this
header will be attached to my message.

Unfortunately,After trying hard, I couldn't figure out how to add the
unmarshaled payload as header, and how to make my bean read that header.

I tried something like :
    from("topic1").setHeader("Student").end()
                         .choice()
                        .when().method("mymethod","isstudent")
                        .to("seda:a");

But I can't find anywhere to put unmarshal() on the header.


Claus Ibsen-2 wrote:
> 
> On Mon, May 18, 2009 at 12:41 AM, uprooter <uprooter@gmail.com> wrote:
>>
>> Hello All.
>> I have this DSL that routes messages from topic1 to topic2.
>> The  messages on topic1 are marshaled POJOs and I can happily unmarshal
>> them.
>>  from("topic1").unmarshal(jaxb).choice()
>>                      
>>  .when().method("mymethod","isStudent").to("topic2")
>>
>> The problem is that when I forward them to topic2 the payload is lost and
>> instead of getting ActiveMQTextMessage I only get ActiveMQMessage without
>> the text payload and I cannot cast them to TextMessage anymore.
>> (like, if I do from("topic1").to("topic2") everything works great but
>> unmashalling drops my payload somewhere)
>>
>> I don't want to marshal the data again. only to route them according to
>> my
>> method.
>> Can you please help me figure this out?
>> Many thanks.
> 
> As Willem pointed out you unmarshal the payload from topic1 to JAXB.
> And JAXB is a Java Object (not text).
> So when you send a JAXB object to a JMS destination (topic2) the JMS
> API will use javax.jms.ObjectMessage as the payload type.
> 
> If you want to store it as text then you must convert the payload back
> to text. Either with marshal or convertBodyTo(String.class) etc.
> Depending if the JAXB can reverse its operation.
> 
> 
> Note: In Camel 2.0 we have added options to the JMS producer so you
> can enfore a specify JMS type to use, eg.
> .to("activemq:topic:topic2? jmsMessageType=Text");
> 
> See more here from: Message Mapping between JMS and Camel
> http://camel.apache.org/jms.html
> 
> 
> 
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Why-does-my-JMS-message-type-changes---tp23588615p23588615.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/Why-does-my-JMS-message-type-changes---tp23588615p23593558.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message