You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mateo <ma...@gmail.com> on 2013/08/06 17:45:42 UTC

Multicast with two endpoints when request to the second depends on the response from the first one

Hi all,

I need to send synchronously two different messages to two different
endpoints but before I can create second request I need first get response
from the first endpoint.

I have tried to use multicast pattern but there is separate exchange created
for each outcome so I cannot communicate between them using properties.

.multicast(someMergeStrategy)
	.to(ENDPOINT1)
	.to(ENDPOINT2) // but before I create this second request I need to
retrieve some information from ENDPOINT1's response
.end()
.bean(mergeResponses)

// each of endpoints use different format of messages so I need perform some
conversions here
from(ENDPOINT1)
	.bean(some_converter1)
	.to(EXTERNAL_SERVICE1)
	.bean(some_converter2)

from(ENDPOINT2)
	// here I need to retrieve some data from the first response and then I
should be able to create request for EXTERNAL_SERVICE2
	.bean(some_converter3)
	.to(EXTERNAL_SERVICE2)
	.bean(some_converter4)
	
Is there any nice way to configure such routing? Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/Multicast-with-two-endpoints-when-request-to-the-second-depends-on-the-response-from-the-first-one-tp5736859.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Multicast with two endpoints when request to the second depends on the response from the first one

Posted by Willem jiang <wi...@gmail.com>.
Hi

I think you can just define the route like this.

from("xxx")
.to(ENDPOINT1)
.process("prepare request")
.to(ENDPOINT2)


--  
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 Wednesday, August 7, 2013 at 3:56 AM, mateo wrote:

> But to create request for ENDPOINT2 I need two things: original request (the
> one which was on Exchange while entering multicast) and response from
> ENDPOINT1. And doing this in proposed way I will lost request information
> (in Exchange in out there will be only response from ENDPOINT1).
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Multicast-with-two-endpoints-when-request-to-the-second-depends-on-the-response-from-the-first-one-tp5736859p5736868.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Multicast with two endpoints when request to the second depends on the response from the first one

Posted by Claus Ibsen <cl...@gmail.com>.
Christian is right - the multicast EIP is not sutiable here. See for
example the content enricher eip.

On Tue, Aug 6, 2013 at 9:56 PM, mateo <ma...@gmail.com> wrote:
> But to create request for ENDPOINT2 I need two things: original request (the
> one which was on Exchange while entering multicast) and response from
> ENDPOINT1. And doing this in proposed way I will lost request information
> (in Exchange in out there will be only response from ENDPOINT1).
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Multicast-with-two-endpoints-when-request-to-the-second-depends-on-the-response-from-the-first-one-tp5736859p5736868.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Multicast with two endpoints when request to the second depends on the response from the first one

Posted by mateo <ma...@gmail.com>.
But to create request for ENDPOINT2 I need two things: original request (the
one which was on Exchange while entering multicast) and response from
ENDPOINT1. And doing this in proposed way I will lost request information
(in Exchange in out there will be only response from ENDPOINT1).



--
View this message in context: http://camel.465427.n5.nabble.com/Multicast-with-two-endpoints-when-request-to-the-second-depends-on-the-response-from-the-first-one-tp5736859p5736868.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Multicast with two endpoints when request to the second depends on the response from the first one

Posted by Christian Posta <ch...@gmail.com>.
You don't need multicast for this. Just use to(endpoint).to(endpoint)....


On Tue, Aug 6, 2013 at 8:45 AM, mateo <ma...@gmail.com> wrote:

> Hi all,
>
> I need to send synchronously two different messages to two different
> endpoints but before I can create second request I need first get response
> from the first endpoint.
>
> I have tried to use multicast pattern but there is separate exchange
> created
> for each outcome so I cannot communicate between them using properties.
>
> .multicast(someMergeStrategy)
>         .to(ENDPOINT1)
>         .to(ENDPOINT2) // but before I create this second request I need to
> retrieve some information from ENDPOINT1's response
> .end()
> .bean(mergeResponses)
>
> // each of endpoints use different format of messages so I need perform
> some
> conversions here
> from(ENDPOINT1)
>         .bean(some_converter1)
>         .to(EXTERNAL_SERVICE1)
>         .bean(some_converter2)
>
> from(ENDPOINT2)
>         // here I need to retrieve some data from the first response and
> then I
> should be able to create request for EXTERNAL_SERVICE2
>         .bean(some_converter3)
>         .to(EXTERNAL_SERVICE2)
>         .bean(some_converter4)
>
> Is there any nice way to configure such routing? Thanks!
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Multicast-with-two-endpoints-when-request-to-the-second-depends-on-the-response-from-the-first-one-tp5736859.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta