camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Dynamic uri in <to> uri, derived from <from> uri
Date Fri, 23 Oct 2009 13:45:51 GMT
On Fri, Oct 23, 2009 at 3:23 PM, chris.pond <chris.pond@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

Mime
View raw message