You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dermoritz <ta...@hotmail.com> on 2015/10/01 08:56:10 UTC

Camel ExchangeCompletedEvent vs. RoutePolicy.onExchangeDone

My camel route is configured like this (pseudocode)

from(direct:in).to(jdbc:db).split().body().streaming().parallelProcessing()
.process(doSomething).process(createDBquery).out(jdbc:db)

The jdbc endpoint is configured to put out JdbcOutputType.StreamList. The
route is triggered by sending a select query into direct:in. Each line from
db is handled in doSomething. It creates a special result object that is
converted into a query to write the result into db.

My main problem is how to detect if the complete result from db was handled-
I want to know when it is finished.

I tried to use an EventNotifier and filtered on ExchangeCompletedEvent. But
this event seems to be raised for every result written into db. Now i am
considering the use of RoutePolicy / overriding "onExchangeDone" but would
this change anything?

What are the exact semantics of both especially for routes that create new
exchanges (e.g. by split) on their way? Is their a clean way to detect when
my route is finished?



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-ExchangeCompletedEvent-vs-RoutePolicy-onExchangeDone-tp5772140.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel ExchangeCompletedEvent vs. RoutePolicy.onExchangeDone

Posted by dermoritz <ta...@hotmail.com>.
Thanks,

that makes many things much clearer :-)



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-ExchangeCompletedEvent-vs-RoutePolicy-onExchangeDone-tp5772140p5772146.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel ExchangeCompletedEvent vs. RoutePolicy.onExchangeDone

Posted by Claus Ibsen <cl...@gmail.com>.
The splitted exchanges have a correlation id that points to its
parent, so you can essential know which exchange is which as the
parent will not have a correlation id.

This is set on the splitted exchanges
        copy.setProperty(Exchange.CORRELATION_ID, id);

And yeah a route policy with the onExchangeDone should call when you
are done, and only for the original exchange as its for routes only

On Thu, Oct 1, 2015 at 9:27 AM, dermoritz <ta...@hotmail.com> wrote:
> Thanks for your quick reply Claus,
>
> my problem is that from inside ExchangeCompletedEvent or onExchangeDone i
> don't know if it is the original exchange or a split exchange. Or: How to
> know if an exchange is the "original exchange"?
> (i know how to detect if a splitter is done, but in my case i only want to
> know about "original message")
>
> To come back to this threads title: Are there semantic differences between
> ExchangeCompletedEvent and RoutePolicy.onExchangeDone?
>
> In meantime i also looked into Camel in Action (a very nice book) and i read
> about "onCompletion" synchronization callbacks i am not sure if those are
> better options for my use case:
>
> camel is called inside another infrastructure (java app that do many other
> things) and i want camel to call back to this infrastructure if the
> "original message" is done.
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-ExchangeCompletedEvent-vs-RoutePolicy-onExchangeDone-tp5772140p5772142.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition

Re: Camel ExchangeCompletedEvent vs. RoutePolicy.onExchangeDone

Posted by dermoritz <ta...@hotmail.com>.
Thanks for your quick reply Claus,

my problem is that from inside ExchangeCompletedEvent or onExchangeDone i
don't know if it is the original exchange or a split exchange. Or: How to
know if an exchange is the "original exchange"?
(i know how to detect if a splitter is done, but in my case i only want to
know about "original message")

To come back to this threads title: Are there semantic differences between
ExchangeCompletedEvent and RoutePolicy.onExchangeDone? 

In meantime i also looked into Camel in Action (a very nice book) and i read
about "onCompletion" synchronization callbacks i am not sure if those are
better options for my use case:

camel is called inside another infrastructure (java app that do many other
things) and i want camel to call back to this infrastructure if the
"original message" is done.






--
View this message in context: http://camel.465427.n5.nabble.com/Camel-ExchangeCompletedEvent-vs-RoutePolicy-onExchangeDone-tp5772140p5772142.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel ExchangeCompletedEvent vs. RoutePolicy.onExchangeDone

Posted by Claus Ibsen <cl...@gmail.com>.
The original exchange will only complete after all the splitter work,
so when that is done you know its done.

Also each splitted exchange has exchange properties that indiciate if
the split is done or not, you could use as alternative to know if the
splitter is done.




On Thu, Oct 1, 2015 at 8:56 AM, dermoritz <ta...@hotmail.com> wrote:
> My camel route is configured like this (pseudocode)
>
> from(direct:in).to(jdbc:db).split().body().streaming().parallelProcessing()
> .process(doSomething).process(createDBquery).out(jdbc:db)
>
> The jdbc endpoint is configured to put out JdbcOutputType.StreamList. The
> route is triggered by sending a select query into direct:in. Each line from
> db is handled in doSomething. It creates a special result object that is
> converted into a query to write the result into db.
>
> My main problem is how to detect if the complete result from db was handled-
> I want to know when it is finished.
>
> I tried to use an EventNotifier and filtered on ExchangeCompletedEvent. But
> this event seems to be raised for every result written into db. Now i am
> considering the use of RoutePolicy / overriding "onExchangeDone" but would
> this change anything?
>
> What are the exact semantics of both especially for routes that create new
> exchanges (e.g. by split) on their way? Is their a clean way to detect when
> my route is finished?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-ExchangeCompletedEvent-vs-RoutePolicy-onExchangeDone-tp5772140.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition