You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "chris.pond" <ch...@bt.com> on 2009/10/22 23:30:11 UTC

Dynamic uri in uri, derived from uri

I'm trying to take JMS messages inside the ActiveMQ broker from a topic
pattern, say "messages.*", and map them to a corresponding JMS queue, say
"queue.${from.topic}" (where ${from.topic} is the topic of the JMS message).
I can't seem to find an easy way to do this. Am I missing something?
I'm looking for something like this:

<route>
  <from uri="messages.*"/>
  <to uri="queue.${from.topic}"/>
</route>

Thanks for any and all help!
-- 
View this message in context: http://www.nabble.com/Dynamic-uri-in-%3Cto%3E-uri%2C-derived-from-%3Cfrom%3E-uri-tp26017552p26017552.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dynamic uri in uri, derived from uri

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 23, 2009 at 3:23 PM, chris.pond <ch...@bt.com> wrote:
>
>
>
> Claus Ibsen-2 wrote:
>>
>> I think you have the from topic as a JMSDestination header on the message.
>> But I havent checked
>>
>> Destination topic = exchange.getIn().getHeader("JMSDestination",
>> Destination.class);
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> Excellent! That's exactly what I need. However, I'm a little at a loss as to
> how to get the "exchange" instance, and then use a method on that within the
> Xml configuration for ActiveMQ. Can I just use JUEL, something like:
> <route>
>  <from uri="messages.*"/>
>  <to uri="queue.${in.headers.JMSDestination}"/>
> </route>
>
> If this works, I'd also like to strip off the "topic://" at the front of the
> JMSDestination. Can I do this with a substring() call, like this?
> ...
>  <to uri="queue.${in.headers.JMSDestination.substring(8)}"/>
> ...

The JMSDestination is a real javax.jms.Destination object and it may
print out a nice jms name if you invoke its toString.

Otherwise there is the getTopicName for the Topic destination.

You cannot do this
  <to uri="queue.${in.headers.JMSDestination.substring(8)}"/>
As you cannot do that in spring.

However you can use a recipient list to compute where to go
http://camel.apache.org/recipient-list.html

This is the correct EIP to use in your use case

Then just compute the endpoint using juel or whatever and store it in a header

<from uri=.../>
<setHeader name="foo">
   <juel>queue.${in.headers.JMSDestination.topicName()}</juel>
</setHeader>
<recipientList>
    <header>foo</header>
</recipientList>




> Thanks!
>
>
> --
> View this message in context: http://www.nabble.com/Dynamic-uri-in-%3Cto%3E-uri%2C-derived-from-%3Cfrom%3E-uri-tp26017552p26026377.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamic uri in uri, derived from uri

Posted by "chris.pond" <ch...@bt.com>.


Claus Ibsen-2 wrote:
> 
> I think you have the from topic as a JMSDestination header on the message.
> But I havent checked
> 
> Destination topic = exchange.getIn().getHeader("JMSDestination",
> Destination.class);
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

Excellent! That's exactly what I need. However, I'm a little at a loss as to
how to get the "exchange" instance, and then use a method on that within the
Xml configuration for ActiveMQ. Can I just use JUEL, something like:
<route>
  <from uri="messages.*"/>
  <to uri="queue.${in.headers.JMSDestination}"/>
</route>

If this works, I'd also like to strip off the "topic://" at the front of the
JMSDestination. Can I do this with a substring() call, like this?
...
  <to uri="queue.${in.headers.JMSDestination.substring(8)}"/>
...

Thanks!


-- 
View this message in context: http://www.nabble.com/Dynamic-uri-in-%3Cto%3E-uri%2C-derived-from-%3Cfrom%3E-uri-tp26017552p26026377.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dynamic uri in uri, derived from uri

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Oct 22, 2009 at 11:30 PM, chris.pond <ch...@bt.com> wrote:
>
> I'm trying to take JMS messages inside the ActiveMQ broker from a topic
> pattern, say "messages.*", and map them to a corresponding JMS queue, say
> "queue.${from.topic}" (where ${from.topic} is the topic of the JMS message).
> I can't seem to find an easy way to do this. Am I missing something?
> I'm looking for something like this:
>
> <route>
>  <from uri="messages.*"/>
>  <to uri="queue.${from.topic}"/>
> </route>
>
> Thanks for any and all help!

I think you have the from topic as a JMSDestination header on the message.
But I havent checked

Destination topic = exchange.getIn().getHeader("JMSDestination",
Destination.class);



> --
> View this message in context: http://www.nabble.com/Dynamic-uri-in-%3Cto%3E-uri%2C-derived-from-%3Cfrom%3E-uri-tp26017552p26017552.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus