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 Wolf <cw...@gmail.com> on 2013/04/12 02:08:48 UTC

Is there a way to programmatically get the the downstream endpoint from a custom Processor?

Hello,

I'm implementing a custom Processor - it will have a ProducerTemplate,
which will always
send to the next Endpoint, downstream - why do I have to set the
defaultEndpoint
or defaultEndpointURI?  That guarantees hardcoding.  Isn't there someway to
indicate,
upon CamelContext.createProducerTemplate() to imply next downstream
Endpoint?

It's not a show-stopper, I can explicitly configure the Producer
defaultEndpoint, but I don't
know why it can't default to the next down-stream consuming endpoint...

Thanks,

Chris

Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

Posted by Chris Wolf <cw...@gmail.com>.
I can see how that would work, but if I'm going to register the
down-stream endpoint,
I may as well just set the ProducerTemplate, but it's an interesting idea..

On Fri, Apr 12, 2013 at 12:35 PM, Raul Kripalani <ra...@evosent.com> wrote:
> One solution is to parametrize the downstream endpoint in the Registry.
>
> from("...").process(new MyProcessor()).to(myDownstreamEndpoint);
>
> where myDownstreamEndpoint is a bean property of type String that gets
> injected via Spring or Blueprint during the route initialization.
>
> It should always have the same bean name in all contexts, e.g.
> ("myDownstreamEndpoint"), so then from MyProcessor you can do the following
> lookup:
>
> String uri = exchange.getRegistry().lookup("myDownstreamEndpoint",
> String.class);
>
> The condition is, of course, that all Camel Contexts using this processor
> must have this property in their Application/Blueprint Contexts.
>
> Hope that helps,
>
> *Raúl Kripalani*
> Enterprise Architect, Open Source Integration specialist, Program
> Manager | Apache
> Camel Committer
> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Fri, Apr 12, 2013 at 4:36 PM, Chris Wolf <cw...@gmail.com> wrote:
>
>> The reason I asked is because now I have to set default Endpoint or URI in
>> the producer template - it would be nice if the default setting would be
>> the next down-stream endpoint.
>>
>>
>> On Thu, Apr 11, 2013 at 8:53 PM, Willem jiang <willem.jiang@gmail.com
>> >wrote:
>>
>> > ProducerTemplate can send the exchange to any other endpoints.
>> > Processor is decoupled with the camel route, I don't think you can get
>> the
>> > downstream endpoint from the custom Processor itself.
>> >
>> >
>> > --
>> > Willem Jiang
>> >
>> > Red Hat, Inc.
>> > FuseSource is now part of Red Hat
>> > Web: http://www.fusesource.com | http://www.redhat.com
>> > Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
>> > (English)
>> >           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
>> > Twitter: willemjiang
>> > Weibo: 姜宁willem
>> >
>> >
>> >
>> >
>> >
>> > On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:
>> >
>> > > Hello,
>> > >
>> > > I'm implementing a custom Processor - it will have a ProducerTemplate,
>> > > which will always
>> > > send to the next Endpoint, downstream - why do I have to set the
>> > > defaultEndpoint
>> > > or defaultEndpointURI? That guarantees hardcoding. Isn't there someway
>> to
>> > > indicate,
>> > > upon CamelContext.createProducerTemplate() to imply next downstream
>> > > Endpoint?
>> > >
>> > > It's not a show-stopper, I can explicitly configure the Producer
>> > > defaultEndpoint, but I don't
>> > > know why it can't default to the next down-stream consuming endpoint...
>> > >
>> > > Thanks,
>> > >
>> > > Chris
>> >
>> >
>> >
>>

Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

Posted by Raul Kripalani <ra...@evosent.com>.
One solution is to parametrize the downstream endpoint in the Registry.

from("...").process(new MyProcessor()).to(myDownstreamEndpoint);

where myDownstreamEndpoint is a bean property of type String that gets
injected via Spring or Blueprint during the route initialization.

It should always have the same bean name in all contexts, e.g.
("myDownstreamEndpoint"), so then from MyProcessor you can do the following
lookup:

String uri = exchange.getRegistry().lookup("myDownstreamEndpoint",
String.class);

The condition is, of course, that all Camel Contexts using this processor
must have this property in their Application/Blueprint Contexts.

Hope that helps,

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Apr 12, 2013 at 4:36 PM, Chris Wolf <cw...@gmail.com> wrote:

> The reason I asked is because now I have to set default Endpoint or URI in
> the producer template - it would be nice if the default setting would be
> the next down-stream endpoint.
>
>
> On Thu, Apr 11, 2013 at 8:53 PM, Willem jiang <willem.jiang@gmail.com
> >wrote:
>
> > ProducerTemplate can send the exchange to any other endpoints.
> > Processor is decoupled with the camel route, I don't think you can get
> the
> > downstream endpoint from the custom Processor itself.
> >
> >
> > --
> > Willem Jiang
> >
> > Red Hat, Inc.
> > FuseSource is now part of Red Hat
> > Web: http://www.fusesource.com | http://www.redhat.com
> > Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> > (English)
> >           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> > Twitter: willemjiang
> > Weibo: 姜宁willem
> >
> >
> >
> >
> >
> > On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:
> >
> > > Hello,
> > >
> > > I'm implementing a custom Processor - it will have a ProducerTemplate,
> > > which will always
> > > send to the next Endpoint, downstream - why do I have to set the
> > > defaultEndpoint
> > > or defaultEndpointURI? That guarantees hardcoding. Isn't there someway
> to
> > > indicate,
> > > upon CamelContext.createProducerTemplate() to imply next downstream
> > > Endpoint?
> > >
> > > It's not a show-stopper, I can explicitly configure the Producer
> > > defaultEndpoint, but I don't
> > > know why it can't default to the next down-stream consuming endpoint...
> > >
> > > Thanks,
> > >
> > > Chris
> >
> >
> >
>

Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

Posted by Chris Wolf <cw...@gmail.com>.
The reason I asked is because now I have to set default Endpoint or URI in
the producer template - it would be nice if the default setting would be
the next down-stream endpoint.


On Thu, Apr 11, 2013 at 8:53 PM, Willem jiang <wi...@gmail.com>wrote:

> ProducerTemplate can send the exchange to any other endpoints.
> Processor is decoupled with the camel route, I don't think you can get the
> downstream endpoint from the custom Processor itself.
>
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
>
> On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:
>
> > Hello,
> >
> > I'm implementing a custom Processor - it will have a ProducerTemplate,
> > which will always
> > send to the next Endpoint, downstream - why do I have to set the
> > defaultEndpoint
> > or defaultEndpointURI? That guarantees hardcoding. Isn't there someway to
> > indicate,
> > upon CamelContext.createProducerTemplate() to imply next downstream
> > Endpoint?
> >
> > It's not a show-stopper, I can explicitly configure the Producer
> > defaultEndpoint, but I don't
> > know why it can't default to the next down-stream consuming endpoint...
> >
> > Thanks,
> >
> > Chris
>
>
>

Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

Posted by Willem jiang <wi...@gmail.com>.
ProducerTemplate can send the exchange to any other endpoints.
Processor is decoupled with the camel route, I don't think you can get the downstream endpoint from the custom Processor itself.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:

> Hello,
>  
> I'm implementing a custom Processor - it will have a ProducerTemplate,
> which will always
> send to the next Endpoint, downstream - why do I have to set the
> defaultEndpoint
> or defaultEndpointURI? That guarantees hardcoding. Isn't there someway to
> indicate,
> upon CamelContext.createProducerTemplate() to imply next downstream
> Endpoint?
>  
> It's not a show-stopper, I can explicitly configure the Producer
> defaultEndpoint, but I don't
> know why it can't default to the next down-stream consuming endpoint...
>  
> Thanks,
>  
> Chris