You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by geoffreydv <ge...@gmail.com> on 2013/10/30 11:29:42 UTC

Waiting for a bean to finish before continuing route

Hello,

I was wondering if something I have in mind is possible using Camel.

Our projects needs a route to listen for jms messages, then persist
something to the database in a custom bean using another route and only
continue the first route once the item has been successfully persisted.

I was hoping something like this would work:

<route id="handle-requests">
            <from uri="activemq:incoming-request"/>
            <bean ref="randomBean" method="doSomething"/>
            <to uri="activemq:persist-request"/>
            <bean ref="itemPersistedActivator" method="doSomething"/>
        </route>

        <route id="persist-request">
            <from uri="activemq:persist-request"/>
            <bean ref="requestPersister" method="persistRequest"/>
        </route>

What I need is the itemPersistedActivator bean's method to only be called
when the request has been persisted to the database. I have simulated a
waiting time in the requestPersister (5 seconds). Currently the route
continues as the message has been dispatched.

Any ideas on this?
Thanks




--
View this message in context: http://camel.465427.n5.nabble.com/Waiting-for-a-bean-to-finish-before-continuing-route-tp5742398.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Waiting for a bean to finish before continuing route

Posted by geoffreydv <ge...@gmail.com>.
The reason I created the persistence route is that there will be other routes
calling this one that do not have to perform any actions afterwards. Do you
have any example on what you mean with publishing an event to signal the
persisting is completed?



--
View this message in context: http://camel.465427.n5.nabble.com/Waiting-for-a-bean-to-finish-before-continuing-route-tp5742398p5742422.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Waiting for a bean to finish before continuing route

Posted by Christian Posta <ch...@gmail.com>.
Well using queues is typically used for asynchronous (or non-blocking)
conversations.
The route doing the persistence would have to publish an event that
signifies "persistence has completed" ... and your first route block until
you've received that (a sort of "request-reply" of sorts).


On Wed, Oct 30, 2013 at 3:29 AM, geoffreydv <ge...@gmail.com> wrote:

> Hello,
>
> I was wondering if something I have in mind is possible using Camel.
>
> Our projects needs a route to listen for jms messages, then persist
> something to the database in a custom bean using another route and only
> continue the first route once the item has been successfully persisted.
>
> I was hoping something like this would work:
>
> <route id="handle-requests">
>             <from uri="activemq:incoming-request"/>
>             <bean ref="randomBean" method="doSomething"/>
>             <to uri="activemq:persist-request"/>
>             <bean ref="itemPersistedActivator" method="doSomething"/>
>         </route>
>
>         <route id="persist-request">
>             <from uri="activemq:persist-request"/>
>             <bean ref="requestPersister" method="persistRequest"/>
>         </route>
>
> What I need is the itemPersistedActivator bean's method to only be called
> when the request has been persisted to the database. I have simulated a
> waiting time in the requestPersister (5 seconds). Currently the route
> continues as the message has been dispatched.
>
> Any ideas on this?
> Thanks
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Waiting-for-a-bean-to-finish-before-continuing-route-tp5742398.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



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