You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by fachhoch <fa...@gmail.com> on 2011/12/08 16:22:45 UTC

using camel to call multiple web services asynchronously

I call  a webservice for my application for a user action, I have spring,cxf  
client , I use this client to call the webservice, now our requirement added
new webservice call , so I have to call two webservices , the old one and
the new one, my initial plan  is in a method I will call  each  webservice,  
club the result return the result, this will take more time as I have to
wait  for   first  webservice to  return result then call second webservice
, other way is to call each webservice in a thread  asynchronously this way
both webservices are called at the same time , an overall time is
reduced,does camel has anything inbuilt for calling multiple webservices
asynchronously ?


--
View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5059120.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using camel to call multiple web services asynchronously

Posted by Freeman Fang <fr...@gmail.com>.
Or for using cxf, you can also use JAX-WS asynchronous invocation  
model directly, which allows the client thread to continue after
making a two-way invocation without being blocked while awaiting a
response from the server, you can check jaxws_async example shipped  
with cxf kit to get more details.

Freeman
On 2011-12-9, at 下午12:51, Claus Ibsen wrote:

> On Thu, Dec 8, 2011 at 4:22 PM, fachhoch <fa...@gmail.com> wrote:
>> I call  a webservice for my application for a user action, I have  
>> spring,cxf
>> client , I use this client to call the webservice, now our  
>> requirement added
>> new webservice call , so I have to call two webservices , the old  
>> one and
>> the new one, my initial plan  is in a method I will call  each   
>> webservice,
>> club the result return the result, this will take more time as I  
>> have to
>> wait  for   first  webservice to  return result then call second  
>> webservice
>> , other way is to call each webservice in a thread  asynchronously  
>> this way
>> both webservices are called at the same time , an overall time is
>> reduced,does camel has anything inbuilt for calling multiple  
>> webservices
>> asynchronously ?
>>
>
> The ProducerTemplate have API for invoking async with either a Future
> as return value, or a callback.
> Then you can use that API from a Java bean and invoke the 2 web
> services async, and assemble the replies using the Java API.
>
> Some details here
> http://camel.apache.org/async
>
> As well the JavaDoc of the ProducerTemplate
>
>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5059120.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> -- 
> 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/

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: using camel to call multiple web services asynchronously

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 8, 2011 at 4:22 PM, fachhoch <fa...@gmail.com> wrote:
> I call  a webservice for my application for a user action, I have spring,cxf
> client , I use this client to call the webservice, now our requirement added
> new webservice call , so I have to call two webservices , the old one and
> the new one, my initial plan  is in a method I will call  each  webservice,
> club the result return the result, this will take more time as I have to
> wait  for   first  webservice to  return result then call second webservice
> , other way is to call each webservice in a thread  asynchronously this way
> both webservices are called at the same time , an overall time is
> reduced,does camel has anything inbuilt for calling multiple webservices
> asynchronously ?
>

The ProducerTemplate have API for invoking async with either a Future
as return value, or a callback.
Then you can use that API from a Java bean and invoke the 2 web
services async, and assemble the replies using the Java API.

Some details here
http://camel.apache.org/async

As well the JavaDoc of the ProducerTemplate


>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5059120.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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: using camel to call multiple web services asynchronously

Posted by bvahdat <ba...@swissonline.ch>.
Hi fachhoch,

the example Willem mentioned is good matching case you could consider to
walk through. However in that example there's no asynchronous invocation of
the banks (which's apparently what you want to have) as multicast() invokes
the endpoints one after the other, so that in your case you should add
parallelProcessing() into your DSL, something like:

from("...").multicast().parallelProcessing().to("...", "...");

Babak


--
View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5061070.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using camel to call multiple web services asynchronously

Posted by Willem Jiang <wi...@gmail.com>.
It you take a look at the loan-broker example[1], you can see we could 
send the request to multiple web services at the same time, that could 
also some some time :)

[1]http://camel.apache.org/loan-broker-example.html
On 12/8/11 11:22 PM, fachhoch wrote:
> I call  a webservice for my application for a user action, I have spring,cxf
> client , I use this client to call the webservice, now our requirement added
> new webservice call , so I have to call two webservices , the old one and
> the new one, my initial plan  is in a method I will call  each  webservice,
> club the result return the result, this will take more time as I have to
> wait  for   first  webservice to  return result then call second webservice
> , other way is to call each webservice in a thread  asynchronously this way
> both webservices are called at the same time , an overall time is
> reduced,does camel has anything inbuilt for calling multiple webservices
> asynchronously ?
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5059120.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Re: using camel to call multiple web services asynchronously

Posted by boday <be...@initekconsulting.com>.
sure, take a look at this EIP...http://camel.apache.org/scatter-gather.html


fachhoch wrote
> 
> I call  a webservice for my application for a user action, I have
> spring,cxf   client , I use this client to call the webservice, now our
> requirement added new webservice call , so I have to call two webservices
> , the old one and the new one, my initial plan  is in a method I will call 
> each  webservice,   club the result return the result, this will take more
> time as I have to wait  for   first  webservice to  return result then
> call second webservice , other way is to call each webservice in a thread 
> asynchronously this way both webservices are called at the same time , an
> overall time is reduced,does camel has anything inbuilt for calling
> multiple webservices asynchronously ?
> 


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

--
View this message in context: http://camel.465427.n5.nabble.com/using-camel-to-call-multiple-web-services-asynchronously-tp5059120p5059642.html
Sent from the Camel - Users mailing list archive at Nabble.com.