Re: OnCompletion issue in Camel-ActiveMQ

2013-11-08 Thread Christian Posta
Jay,

I think you had it mostly correct. I wrote a unit test that shows it
working here:

https://github.com/christian-posta/camel-sandbox/blob/master/camel-2.12.1-issues/src/test/java/posta/ActiveMQOnCompletionTest.java

Maybe you can check that out and align it with your use case and see
what the difference is?



On Fri, Nov 8, 2013 at 3:13 AM, jay  wrote:
> Hi, Thanks a lot for your views. i will try to look into the Camel route
> timing option. Have a good weekend.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/OnCompletion-issue-in-Camel-ActiveMQ-tp5742771p5742824.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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


Re: OnCompletion issue in Camel-ActiveMQ

2013-11-08 Thread jay
Hi, Thanks a lot for your views. i will try to look into the Camel route
timing option. Have a good weekend.



--
View this message in context: 
http://camel.465427.n5.nabble.com/OnCompletion-issue-in-Camel-ActiveMQ-tp5742771p5742824.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: OnCompletion issue in Camel-ActiveMQ

2013-11-08 Thread Claus Ibsen
onCompletion is per message.

If you route from a JMS queue then its also per message, and there is
no easy way of knowing that the queue is empty.

You would need to think about alternative way of figuring out if the
queue is empty. Depending on the message broker you use, they may have
some API to support that.

For example Apache ActiveMQ has advisory messages you can use to send
a message to a queue, and get back a reply message with the current
stats of the queue.

You can also have some way like if there has not been any new message
picked up from the Camel route in X time, then we assume the queue is
empty.

You can also use the aggregator EIP and aggregate all the messages
from the queue. And then use a timeout completion on the aggregator,
then that timeout is hit when the is empty, as there was no new
messages in X time.





On Thu, Nov 7, 2013 at 11:03 AM, jay  wrote:
> Hi Guys,
>
> I have a requirement to call some bean/pojo or processor to clean some stuff
> once all the messages are processed from the queue (_from).
>
> But my on completion is getting invoked for every single message. Could
> someone let me know your views on what is wrong i am doing here.
>
> below is my code :
> onCompletion().beanRef("MyBean", "xyzMethod");
> from(_from).routeId("myRouteID")
> .process(new MyProcessor())
> .choice()
>.when(header("VALID_MSG").isEqualTo("false" ))
>.log(" Error")
>.otherwise()
>.aggregate( header("ID"), new
> MyAggregator()).completionTimeout(getAggregationTimeout())
>.process(processor);
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/OnCompletion-issue-in-Camel-ActiveMQ-tp5742771.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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