git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call async bean problem


Hi

You can use AsyncProcessor and .process instead of the bean, and then
use the AsyncCallback to continue routing when you have the result
from the web endpoint.

If you do not mind you can likely also add some logic to your bean
method that will wait for the web result before you return, but then
that thread is waiting/blocking.

On Fri, Mar 16, 2018 at 5:16 PM, Marco Westermann <MarWestermann@xxxxxx> wrote:
> Hi camel riders,
>
> I have a problem with a route which needs to call a bean but the bean itself
> is async (rxjava2)
>
> My route is created in a vertx verticle using eventbus bridge.
>
> my route looks like:
>
> from("direct:process")
>
>     .bean("myProcessor", "process")
>
>     .to("log:bodyAfterProcessing")
>
>
> Now the process method uses vertx webClient async (rxjava2) to call a web
> endpoint and then sets the body of the exchange to the result of the call.
>
> But of cause this does not block the method itself which leads to the route
> already continue while the process method does not really finish.
>
> Is there a solution that I can "wait" for async methods to finish?
>
> Best regards,
>
> Marco
>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2



( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03156.html on line 117
Call Stack
#TimeMemoryFunctionLocation
10.0005364424{main}( ).../msg03156.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03156.html on line 117
Call Stack
#TimeMemoryFunctionLocation
10.0005364424{main}( ).../msg03156.html:0