Async reques/response

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Async reques/response

Mohit Anchlia
I am looking for an example that does the following:

1. Read a String (json)
2. post it to a queue
3. Get the response

So far I've seen examples that involve "from" and "to" but my "from" is a
string.

Also, I am planning to use it in a standalone jvm application.
Reply | Threaded
Open this post in threaded view
|

Re: Async reques/response

edmondo1984
Hello,

in Camel you need endpoint to be able to "produce" or "consume" data.

So your route DSL look like the following : from(producer).to(consumer).

In your case, if you don't have a proper producer, you can use a "direct" endpoint or a "seda" endpoint

from("direct:input").to("activemq:etcetc")

Then from the code that should produce the string, you will write the following code:

CamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new MySimpleRouteBuilder());
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
Object reply = producerTemplate.requestBody("direct:input","Hello world);


Does it make sense?

Best

Edmondo
Reply | Threaded
Open this post in threaded view
|

Re: Async reques/response

Mohit Anchlia
Yes it does. Let me give it a shot


On Sat, Sep 6, 2014 at 6:33 AM, edmondo1984 <[hidden email]> wrote:

> Hello,
>
> in Camel you need endpoint to be able to "produce" or "consume" data.
>
> So your route DSL look like the following : from(producer).to(consumer).
>
> In your case, if you don't have a proper producer, you can use a "direct"
> endpoint or a "seda" endpoint
>
> from("direct:input").to("activemq:etcetc")
>
> Then from the code that should produce the string, you will write the
> following code:
>
> CamelContext camelContext = new DefaultCamelContext();
> camelContext.addRoutes(new MySimpleRouteBuilder());
> ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
> Object reply = producerTemplate.requestBody("direct:input","Hello world);
>
>
> Does it make sense?
>
> Best
>
> Edmondo
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Async-reques-response-tp5756113p5756116.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Async reques/response

Mohit Anchlia
I started implementing the above but have few questions:

1) I am using activemq connection factory. How does camel know which broker
and url to use to create activemq connection factory.
2) How can I set replyTo queue name as I don't want camel to create new
temp queue for every request.



On Sat, Sep 6, 2014 at 9:35 AM, Mohit Anchlia <[hidden email]>
wrote:

> Yes it does. Let me give it a shot
>
>
> On Sat, Sep 6, 2014 at 6:33 AM, edmondo1984 <[hidden email]>
> wrote:
>
>> Hello,
>>
>> in Camel you need endpoint to be able to "produce" or "consume" data.
>>
>> So your route DSL look like the following : from(producer).to(consumer).
>>
>> In your case, if you don't have a proper producer, you can use a "direct"
>> endpoint or a "seda" endpoint
>>
>> from("direct:input").to("activemq:etcetc")
>>
>> Then from the code that should produce the string, you will write the
>> following code:
>>
>> CamelContext camelContext = new DefaultCamelContext();
>> camelContext.addRoutes(new MySimpleRouteBuilder());
>> ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
>> Object reply = producerTemplate.requestBody("direct:input","Hello world);
>>
>>
>> Does it make sense?
>>
>> Best
>>
>> Edmondo
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Async-reques-response-tp5756113p5756116.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>