You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vanyatka <ib...@gmail.com> on 2008/10/16 17:20:19 UTC
how to inject JMS property to all messages in a queue?
Hi,
I'm merging two queues into one using Virtual Destinations.
<compositeQueue name="virtualQ1">
<forwardTo>
<queue physicalName="physicalQ"/>
</forwardTo>
</compositeQueue>
<compositeQueue name="virtualQ2">
<forwardTo>
<queue physicalName="physicalQ"/>
</forwardTo>
</compositeQueue>
I'd like to separate messages later using JMS property. How can I add a JMS
property to all messages coming from each queue using ActiveMQ
configuration?
Thanks for advice,
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20015597.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by James Strachan <ja...@gmail.com>.
Or run your route in a separate JVM using Camel 1.4.0
2008/10/17 James Strachan <ja...@gmail.com>:
> Looks like you'll need a 5.2 build which comes with Camel 1.4.0
>
> 2008/10/17 vanyatka <ib...@gmail.com>:
>>
>> Which XSD is actually used here?
>> I've looked into AMQ 5.1 and it uses camel 1.3.0
>> The corresponding XSD is
>> http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd
>>
>> But it tells me that
>>
>> Element <setHeader> is not allowed under element <route>.
>> Reason: The following elements are expected at this location (see below)
>> <tns:loadBalance>
>> <tns:throwFault>
>> <tns:finally>
>> <tns:choice>
>> <tns:unmarshal>
>> <tns:resequencer>
>> <tns:multicast>
>> <tns:catch>
>> <tns:to>
>> <tns:process>
>> <tns:onException>
>> <tns:routingSlip>
>> <tns:otherwise>
>> <tns:recipientList>
>> <tns:splitter>
>> <tns:when>
>> <tns:bean>
>> <tns:route>
>> <tns:interceptor>
>> <tns:throttler>
>> <tns:from>
>> <tns:marshal>
>> <tns:proceed>
>> <tns:idempotentConsumer>
>> <tns:thread>
>> <tns:aggregator>
>> <tns:delayer>
>> <tns:filter>
>> <tns:policy>
>> <tns:try>
>> <tns:intercept>
>>
>> :confused:
>>
>> --
>> View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20031065.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: how to inject JMS property to all messages in a queue?
Posted by James Strachan <ja...@gmail.com>.
2008/10/17 vanyatka <ib...@gmail.com>:
>
>
>
> James.Strachan wrote:
>>
>> Looks like you'll need a 5.2 build which comes with Camel 1.4.0
>>
>
> I'd be happy to, but ...
>
> This page is a preview of the download page for Apache ActiveMQ 5.2.0, but
> this release is not official yet.
> The download links will not work. Please, come back in a few days or follow
> the vote thread to see how the release is progressing.
>
> Does it mean I cannot add JMS header using camel 1.3.0?
Not using XML; you could invoke a bean to do it though. Its gonna be
easiest to either use the current release candidate of ActiveMQ 5.2.0
http://people.apache.org/~gtully/staging-repos/activemq-5.2.0/org/apache/activemq/apache-activemq/5.2.0/
or run this route in a separate JVM using Camel 1.4.0 - or use a bean processor
http://activemq.apache.org/camel/bean-integration.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
RE: how to inject JMS property to all messages in a queue?
Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi
You can set the header in Java code
There is a <processRef> tag where you can reference a spring bean id. This bean is just a class that you create and implement the org.apache.camel.Processor interface. Here you can add the header in java code
Public void process(Exchange exchange) {
Exchange.getIn().setHeader("myheaderkey", "myheadervalue");
}
Med venlig hilsen
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: vanyatka [mailto:ibalashov@gmail.com]
Sent: 17. oktober 2008 13:20
To: camel-user@activemq.apache.org
Subject: Re: how to inject JMS property to all messages in a queue?
James.Strachan wrote:
>
> Looks like you'll need a 5.2 build which comes with Camel 1.4.0
>
I'd be happy to, but ...
This page is a preview of the download page for Apache ActiveMQ 5.2.0, but
this release is not official yet.
The download links will not work. Please, come back in a few days or follow
the vote thread to see how the release is progressing.
Does it mean I cannot add JMS header using camel 1.3.0? Now I'm not being
capricious now about valid XSD, I just need it work somehow )
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20031444.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by vanyatka <ib...@gmail.com>.
James.Strachan wrote:
>
> Looks like you'll need a 5.2 build which comes with Camel 1.4.0
>
I'd be happy to, but ...
This page is a preview of the download page for Apache ActiveMQ 5.2.0, but
this release is not official yet.
The download links will not work. Please, come back in a few days or follow
the vote thread to see how the release is progressing.
Does it mean I cannot add JMS header using camel 1.3.0? Now I'm not being
capricious now about valid XSD, I just need it work somehow )
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20031444.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by James Strachan <ja...@gmail.com>.
Looks like you'll need a 5.2 build which comes with Camel 1.4.0
2008/10/17 vanyatka <ib...@gmail.com>:
>
> Which XSD is actually used here?
> I've looked into AMQ 5.1 and it uses camel 1.3.0
> The corresponding XSD is
> http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd
>
> But it tells me that
>
> Element <setHeader> is not allowed under element <route>.
> Reason: The following elements are expected at this location (see below)
> <tns:loadBalance>
> <tns:throwFault>
> <tns:finally>
> <tns:choice>
> <tns:unmarshal>
> <tns:resequencer>
> <tns:multicast>
> <tns:catch>
> <tns:to>
> <tns:process>
> <tns:onException>
> <tns:routingSlip>
> <tns:otherwise>
> <tns:recipientList>
> <tns:splitter>
> <tns:when>
> <tns:bean>
> <tns:route>
> <tns:interceptor>
> <tns:throttler>
> <tns:from>
> <tns:marshal>
> <tns:proceed>
> <tns:idempotentConsumer>
> <tns:thread>
> <tns:aggregator>
> <tns:delayer>
> <tns:filter>
> <tns:policy>
> <tns:try>
> <tns:intercept>
>
> :confused:
>
> --
> View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20031065.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: how to inject JMS property to all messages in a queue?
Posted by vanyatka <ib...@gmail.com>.
Which XSD is actually used here?
I've looked into AMQ 5.1 and it uses camel 1.3.0
The corresponding XSD is
http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd
But it tells me that
Element <setHeader> is not allowed under element <route>.
Reason: The following elements are expected at this location (see below)
<tns:loadBalance>
<tns:throwFault>
<tns:finally>
<tns:choice>
<tns:unmarshal>
<tns:resequencer>
<tns:multicast>
<tns:catch>
<tns:to>
<tns:process>
<tns:onException>
<tns:routingSlip>
<tns:otherwise>
<tns:recipientList>
<tns:splitter>
<tns:when>
<tns:bean>
<tns:route>
<tns:interceptor>
<tns:throttler>
<tns:from>
<tns:marshal>
<tns:proceed>
<tns:idempotentConsumer>
<tns:thread>
<tns:aggregator>
<tns:delayer>
<tns:filter>
<tns:policy>
<tns:try>
<tns:intercept>
:confused:
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20031065.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by James Strachan <ja...@gmail.com>.
2008/10/17 vanyatka <ib...@gmail.com>:
>
>
>
> James.Strachan wrote:
>>
>> You're best bet is to use Camel to create a route to set a header and
>> move messages.
>>
>> <from uri="activemq:virtualQ1">
>> <setHeader name="foo" value="bar"/>
>> <to uri="activemq:physicalQ1"/>
>> </from>
>>
>> then you can use a Content Based Router later on etc.
>>
>>
>
> Thanks for the suggestion. Here is what I added to my activemq.xml file (AMQ
> 5.1 supports camel AFAIK)
>
> <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
> <route>
> <from uri="activemq:virtualQ1" />
> <to uri="activemq:physicalQ"/>
> <setHeader headerName="dest" value="MyValue" id="hID1">
> <simple>simpleTag</simple>
> </setHeader>
You're setting the header after its gone to the queue, switch it around...
<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:virtualQ1" />
<setHeader headerName="dest" value="MyValue" id="hID1">
<simple>simpleTag</simple>
</setHeader>
<to uri="activemq:physicalQ"/>
</route>
</camelContext>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
RE: how to inject JMS property to all messages in a queue?
Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi
You need the *to* last.
from
setHeader
to
Med venlig hilsen
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: vanyatka [mailto:ibalashov@gmail.com]
Sent: 17. oktober 2008 11:30
To: camel-user@activemq.apache.org
Subject: Re: how to inject JMS property to all messages in a queue?
James.Strachan wrote:
>
> You're best bet is to use Camel to create a route to set a header and
> move messages.
>
> <from uri="activemq:virtualQ1">
> <setHeader name="foo" value="bar"/>
> <to uri="activemq:physicalQ1"/>
> </from>
>
> then you can use a Content Based Router later on etc.
>
>
Thanks for the suggestion. Here is what I added to my activemq.xml file (AMQ
5.1 supports camel AFAIK)
<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:virtualQ1" />
<to uri="activemq:physicalQ"/>
<setHeader headerName="dest" value="MyValue" id="hID1">
<simple>simpleTag</simple>
</setHeader>
</route>
</camelContext>
The result is that messages are routed correctly, but they arrive without
JMS String Property "dest".
I modified your example a bit to match the actual xml schema.
I don't understand though why I have to put anything into <setHeader> tag.
But the schema tells me so, and so I did )
If you could spot a mistake in my config, I'd appreciate.
Ivan
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20029984.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by vanyatka <ib...@gmail.com>.
James.Strachan wrote:
>
> You're best bet is to use Camel to create a route to set a header and
> move messages.
>
> <from uri="activemq:virtualQ1">
> <setHeader name="foo" value="bar"/>
> <to uri="activemq:physicalQ1"/>
> </from>
>
> then you can use a Content Based Router later on etc.
>
>
Thanks for the suggestion. Here is what I added to my activemq.xml file (AMQ
5.1 supports camel AFAIK)
<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:virtualQ1" />
<to uri="activemq:physicalQ"/>
<setHeader headerName="dest" value="MyValue" id="hID1">
<simple>simpleTag</simple>
</setHeader>
</route>
</camelContext>
The result is that messages are routed correctly, but they arrive without
JMS String Property "dest".
I modified your example a bit to match the actual xml schema.
I don't understand though why I have to put anything into <setHeader> tag.
But the schema tells me so, and so I did )
If you could spot a mistake in my config, I'd appreciate.
Ivan
--
View this message in context: http://www.nabble.com/how-to-inject-JMS-property-to-all-messages-in-a-queue--tp20015597s22882p20029984.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: how to inject JMS property to all messages in a queue?
Posted by James Strachan <ja...@gmail.com>.
2008/10/16 vanyatka <ib...@gmail.com>:
>
> Hi,
>
> I'm merging two queues into one using Virtual Destinations.
>
> <compositeQueue name="virtualQ1">
> <forwardTo>
> <queue physicalName="physicalQ"/>
> </forwardTo>
> </compositeQueue>
> <compositeQueue name="virtualQ2">
> <forwardTo>
> <queue physicalName="physicalQ"/>
> </forwardTo>
> </compositeQueue>
>
> I'd like to separate messages later using JMS property. How can I add a JMS
> property to all messages coming from each queue using ActiveMQ
> configuration?
You're best bet is to use Camel to create a route to set a header and
move messages.
<from uri="activemq:virtualQ1">
<setHeader name="foo" value="bar"/>
<to uri="activemq:physicalQ1"/>
</from>
then you can use a Content Based Router later on etc.
http://activemq.apache.org/camel/enterprise-integration-patterns.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/