You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Talbut <jt...@tardis.spudsoft> on 2011/07/13 18:07:19 UTC

Best component to use for a synchronous InOut route?

Hi,

I've got a processor that needs to call out to another Camel route (multiple times) to get some data.
The complexities of when it calls out mean that it's not worth trying to put all the logic into one route.

What's the best component to use to make a camel route into a synchronous function that can be called from the same VM?
I could put a web service around the route and call that service from a normal CXF client, but that seems a bit heavyweight.
I could use a direct component to start the route, but that isn't synchronous InOut (or can it be made so?) and it requires me to implement CamelContextAware (to get 
the Endpoint) which is a bit ugly.

Thanks for any pointers.

Jim

Re: Best component to use for a synchronous InOut route?

Posted by Tim <ch...@gmail.com>.
You can always inject yourself with a proxy. Look at camel proxy under
'hiding the middleware'
On Jul 14, 2011 11:42 AM, "Jim Talbut" <jt...@spudsoft.co.uk> wrote:
> Just to say thanks to Claus and Ben.
> I've ended up using @Producer with a direct component - it's not totally
> free of Camel, but it has to have some kind of non-POJO thing in there
> so that's OK.
>
> Jim
>
> On 14/07/2011 05:24, Claus Ibsen wrote:
>> On Wed, Jul 13, 2011 at 6:07 PM, James Talbut<jt...@tardis.spudsoft>
wrote:
>>> Hi,
>>>
>>> I've got a processor that needs to call out to another Camel route
(multiple times) to get some data.
>>> The complexities of when it calls out mean that it's not worth trying to
put all the logic into one route.
>>>
>>> What's the best component to use to make a camel route into a
synchronous function that can be called from the same VM?
>>> I could put a web service around the route and call that service from a
normal CXF client, but that seems a bit heavyweight.
>>> I could use a direct component to start the route, but that isn't
synchronous InOut (or can it be made so?) and it requires me to implement
CamelContextAware (to get
>>> the Endpoint) which is a bit ugly.
>>>
>> You can also use @Produce annotation to reduce the Camel API in your
>> code. And there are other ways. Check some of these links. And if you
>> got the Camel in Action book, you may want to check chapter 14.
>>
>> http://camel.apache.org/pojo-producing.html
>> http://camel.apache.org/hiding-middleware.html
>> http://camel.apache.org/using-camelproxy.html
>>
>>
>>
>>> Thanks for any pointers.
>>>
>>> Jim
>>>
>>
>>
>

Re: Best component to use for a synchronous InOut route?

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
Just to say thanks to Claus and Ben.
I've ended up using @Producer with a direct component - it's not totally 
free of Camel, but it has to have some kind of non-POJO thing in there 
so that's OK.

Jim

On 14/07/2011 05:24, Claus Ibsen wrote:
> On Wed, Jul 13, 2011 at 6:07 PM, James Talbut<jt...@tardis.spudsoft>  wrote:
>> Hi,
>>
>> I've got a processor that needs to call out to another Camel route (multiple times) to get some data.
>> The complexities of when it calls out mean that it's not worth trying to put all the logic into one route.
>>
>> What's the best component to use to make a camel route into a synchronous function that can be called from the same VM?
>> I could put a web service around the route and call that service from a normal CXF client, but that seems a bit heavyweight.
>> I could use a direct component to start the route, but that isn't synchronous InOut (or can it be made so?) and it requires me to implement CamelContextAware (to get
>> the Endpoint) which is a bit ugly.
>>
> You can also use @Produce annotation to reduce the Camel API in your
> code. And there are other ways. Check some of these links. And if you
> got the Camel in Action book, you may want to check chapter 14.
>
> http://camel.apache.org/pojo-producing.html
> http://camel.apache.org/hiding-middleware.html
> http://camel.apache.org/using-camelproxy.html
>
>
>
>> Thanks for any pointers.
>>
>> Jim
>>
>
>


Re: Best component to use for a synchronous InOut route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 13, 2011 at 6:07 PM, James Talbut <jt...@tardis.spudsoft> wrote:
> Hi,
>
> I've got a processor that needs to call out to another Camel route (multiple times) to get some data.
> The complexities of when it calls out mean that it's not worth trying to put all the logic into one route.
>
> What's the best component to use to make a camel route into a synchronous function that can be called from the same VM?
> I could put a web service around the route and call that service from a normal CXF client, but that seems a bit heavyweight.
> I could use a direct component to start the route, but that isn't synchronous InOut (or can it be made so?) and it requires me to implement CamelContextAware (to get
> the Endpoint) which is a bit ugly.
>

You can also use @Produce annotation to reduce the Camel API in your
code. And there are other ways. Check some of these links. And if you
got the Camel in Action book, you may want to check chapter 14.

http://camel.apache.org/pojo-producing.html
http://camel.apache.org/hiding-middleware.html
http://camel.apache.org/using-camelproxy.html



> Thanks for any pointers.
>
> Jim
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Best component to use for a synchronous InOut route?

Posted by boday <be...@initekconsulting.com>.
James, direct is synchronous and can return a response...just use a
ProducerTemplate in your processor to call the route like this...you also
should reuse the producer template if there is a high volume of calls

Object result =
exchange.getContext().createProducerTemplate().requestBody("direct:start","input
message");

from("direct:start").setBody(simple("processed ${body}"));


James Talbut wrote:
> 
> Hi,
> 
> I've got a processor that needs to call out to another Camel route
> (multiple times) to get some data.
> The complexities of when it calls out mean that it's not worth trying to
> put all the logic into one route.
> 
> What's the best component to use to make a camel route into a synchronous
> function that can be called from the same VM?
> I could put a web service around the route and call that service from a
> normal CXF client, but that seems a bit heavyweight.
> I could use a direct component to start the route, but that isn't
> synchronous InOut (or can it be made so?) and it requires me to implement
> CamelContextAware (to get 
> the Endpoint) which is a bit ugly.
> 
> Thanks for any pointers.
> 
> Jim
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/Best-component-to-use-for-a-synchronous-InOut-route-tp4583148p4583755.html
Sent from the Camel - Users mailing list archive at Nabble.com.