Persistent Header

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Persistent Header

Castyn
I have a route which hits an active MQ point external to my system and outside of my control.  I've tried creating a header before the queue, and then capturing it afterwards but the queue I am hitting (actually another instance of Servicemix with activeMQ) does not persist it along with the message and eventually the response.  Is there a way for me to persist a piece of data quickly and easily that I can set before the external queue component and then retrieve afterwards?

Example of what I am doing:


<setHeader headerName="theCode">
        <constant>ABCDE</constant>
</setHeader>
<inOut uri="activemqhcm:queue:JMS/EXT.ESB.REQ"/> 
<setBody>
       <simple>${headers.theCode}</simple>
</setBody>
<to uri="file:data?fileName=test.xml"/>

Reply | Threaded
Open this post in threaded view
|

Re: Persistent Header

Freeman-2
Hi,

In this case I think you need store the date as properties for  
exchange but not the headers for the message.
The exchange keep alive during whole InOut conversation.


Freeman
On 2011-11-30, at 上午6:25, Castyn wrote:

> I have a route which hits an active MQ point external to my system and
> outside of my control.  I've tried creating a header before the  
> queue, and
> then capturing it afterwards but the queue I am hitting (actually  
> another
> instance of Servicemix with activeMQ) does not persist it along with  
> the
> message and eventually the response.  Is there a way for me to  
> persist a
> piece of data quickly and easily that I can set before the external  
> queue
> component and then retrieve afterwards?
>
> Example of what I am doing:
>
>
> <setHeader headerName="theCode">
>        <constant>ABCDE</constant>
> </setHeader>
> <inOut uri="activemqhcm:queue:JMS/EXT.ESB.REQ"/>
> <setBody>
>       <simple>${headers.theCode}</simple>
> </setBody>
> <to uri="file:data?fileName=test.xml"/>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Persistent-Header-tp5033912p5033912.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:[hidden email]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com









Reply | Threaded
Open this post in threaded view
|

Re: Persistent Header

Willem.Jiang
Administrator
Just as Freeman said, the message header will be override by the
components,
but the property of the exchange can be copied from one endpoint to
another endpoint.
 
On Wed Nov 30 10:42:49 2011, Freeman Fang wrote:

> Hi,
>
> In this case I think you need store the date as properties for
> exchange but not the headers for the message.
> The exchange keep alive during whole InOut conversation.
>
>
> Freeman
> On 2011-11-30, at 上午6:25, Castyn wrote:
>
>> I have a route which hits an active MQ point external to my system and
>> outside of my control. I've tried creating a header before the queue,
>> and
>> then capturing it afterwards but the queue I am hitting (actually
>> another
>> instance of Servicemix with activeMQ) does not persist it along with the
>> message and eventually the response. Is there a way for me to persist a
>> piece of data quickly and easily that I can set before the external
>> queue
>> component and then retrieve afterwards?
>>
>> Example of what I am doing:
>>
>>
>> <setHeader headerName="theCode">
>> <constant>ABCDE</constant>
>> </setHeader>
>> <inOut uri="activemqhcm:queue:JMS/EXT.ESB.REQ"/>
>> <setBody>
>> <simple>${headers.theCode}</simple>
>> </setBody>
>> <to uri="file:data?fileName=test.xml"/>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Persistent-Header-tp5033912p5033912.html 
>>
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------
> Freeman Fang
>
> FuseSource
> Email:[hidden email]
> Web: fusesource.com
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
>
>
>
>
>
>
>
>
>
>



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

Reply | Threaded
Open this post in threaded view
|

Re: Persistent Header

Castyn
Thanks, makes sense.  I see how to set and get properties via the Exchange java object, is there a way to do this in the Spring DSL on the camel route, or do I need to create a simple processor on each end of the inOut call?
Reply | Threaded
Open this post in threaded view
|

Re: Persistent Header

Castyn
I tried

                        <setProperty propertyName="theCode">
                                <constant>ABCDE</constant>
                        </setProperty>
                        <to uri="activemq:EXT.REQ"/>

then in the other part of the route in the same context:

                        <from uri="activemq:EXT.REQ"/>
                        <to uri="myProcessor"/>
                        <to uri="file:data/hcm?fileName=hotelUpdateRequest.xml"/>

Within the custom processor I have
String theCode = exchange.getProperty("theCode", String.class);
But it is not returning a value.
Reply | Threaded
Open this post in threaded view
|

Re: Persistent Header

Claus Ibsen-2
Hi

Read the JMS wiki page, how Camel maps to/from JMS. And especially
about JMS limitations for headers.


On Wed, Nov 30, 2011 at 4:16 PM, Castyn <[hidden email]> wrote:
> I tried
>
>                        <setProperty propertyName="theCode">
>                                <constant>ABCDE</constant>
>                        </setProperty>
>                        <to uri="activemq:EXT.REQ"/>
>
> then in the other part of the route in the same context:
>

only body + headers is part of what data JMS send over.


>                        <from uri="activemq:EXT.REQ"/>
>                        <to uri="myProcessor"/>
>                        <to uri="file:data/hcm?fileName=hotelUpdateRequest.xml"/>
>
> Within the custom processor I have
> String theCode = exchange.getProperty("theCode", String.class);
> But it is not returning a value.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Persistent-Header-tp5033912p5035817.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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