You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by trivedi kumar b <Tr...@ge.com> on 2009/12/09 04:07:20 UTC
Accessing exchange from producer template
Hi,
I have a bean that is being invoked from a route and this bean has got
producer template.. and I want the access to exchange object to retrieve
properties that is being set before in the route. So I have written a small
piece of code (method) that returns me the exchange object.. pls let me know
if there is a better to get the exchange object.
private Exchange getExchange() {
Exchange exchange = template.send(new Processor() {
public void process(Exchange arg0) throws Exception { }
});
return exchange;
}
--
View this message in context: http://old.nabble.com/Accessing-exchange-from-producer-template-tp26704478p26704478.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Accessing exchange from producer template
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 9, 2009 at 4:07 AM, trivedi kumar b
<Tr...@ge.com> wrote:
>
> Hi,
>
> I have a bean that is being invoked from a route and this bean has got
> producer template.. and I want the access to exchange object to retrieve
> properties that is being set before in the route. So I have written a small
> piece of code (method) that returns me the exchange object.. pls let me know
> if there is a better to get the exchange object.
>
Hi
You want to get those properties in the bean, and before you use the
producer template?
You can use bean parameter binding
http://camel.apache.org/parameter-binding-annotations.html
public void myMethod(String body, @Properties Map properties);
Or just add Exchange as a parameter to your bean.
public void myMethod(String body, Exchange exchange);
PS: Chapter 4 in Camel in Action covers using beans in great details
> private Exchange getExchange() {
> Exchange exchange = template.send(new Processor() {
> public void process(Exchange arg0) throws Exception { }
> });
> return exchange;
> }
> --
> View this message in context: http://old.nabble.com/Accessing-exchange-from-producer-template-tp26704478p26704478.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