You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by StevenD <st...@gmail.com> on 2012/01/02 13:06:06 UTC
Re: Howto use delay message brokerage in a Camel Route using
AMQ_SCHEDULED_DELAY
Thanks, this was really helpful. I noticed however that the delay only worked
for the first retry, all subsequent retries would be handled immediately. I
solved this by resetting the scheduledJobId back to null just before sending
it back to the queue. My exception handler now looks like:
...
.onException(Exception.class)
.handled(true)
.beanRef("dispatchRetryTagger")
.choice()
.when(header("dispatchRetryCount").isLessThan(3))
.setHeader("AMQ_SCHEDULED_DELAY", constant("4000"))
.setHeader("scheduledJobId", constant(null))
.to("activemq:queue:myqueue")
.otherwise()
.removeHeader("AMQ_SCHEDULED_DELAY")
.to("direct:dlq")
.end()
--
View this message in context: http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5114568.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto use delay message brokerage in a Camel Route using
AMQ_SCHEDULED_DELAY
Posted by garrydias <ga...@gmail.com>.
I found the problem. Is something between Eclipse and Maven Plugin
(M2Eclipse).
When I ran /mvn clean install -e/ my test cases were executed by Maven
lifecycle.
My testCases has a Thread.sleep(10000) at the last line. Sometimes, I did
not wait these 10 seconds and I killed Maven process through the red square
in Eclipse console view. When I did that, the process was killed within
Eclipse but not in Windows (7) OS. Through Windows Task Manager I could see
a "java" process running for every time I ran /mvn clean install -e/. And
each process was an activemq consumer. When I killed one of these "zombie"
process the consumer amount was decreased in the activemq web console.
So, before discover this, I had at least dozens of java processes running a
single activemq consumer for *activemq:destination* and each process was
represented by different versions of my program. Weird things could have
happened, like the exception I had posted before.
When I killed all java proccess via Task Manager my application consumed
scheduled messages succesffuly...
However, now scheduled messages (using AMQ_SCHEDULED_CRON) are succesfully
consumed... but once. In Activemq Web Console (/Scheduled/ menu) the field
/next scheduled time/ shows the next date to consume the message but when
the current time matches with this field, the message is not consumed but
/next scheduled time/ is recalculated.
- I used this cron for tests: *1,2,3,4,5,6,7,8 * * * **;
- I started my app at 4:00AM;
- 4:01AM the message WAS consumed and /next scheduled time/ was recalculated
to 4:02AM
- 4:02AM the message WAS NOT consumed and /next scheduled time/ was
recalculated to 4:03AM
- 4:03AM the message WAS NOT consumed and /next scheduled time/ was
recalculated to 4:04AM
and so on...
After 4:08AM the /next scheduled time/ was recalculated to 5:01AM. Normal
behavior! Except for the failure in consumption.
Consume the first scheduling is a normal behavior for AMQ scheduled
messages?
Thanx again
--
View this message in context: http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5724423.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto use delay message brokerage in a Camel Route using
AMQ_SCHEDULED_DELAY
Posted by garrydias <ga...@gmail.com>.
Correct Claus! Thanks for your answer.
As I just explained, one of the "zombie" process running in background was
related to a version of my app where /method/ option was not set in my bean
endpoint definition.
When I killed all zombie processes and ran my last app version (with
/bean:destinationConsumer?method=consume/ definition) the problem was
(almost*) solved.
* My previous post explains the consumption only once.
[]s
--
View this message in context: http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5724428.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto use delay message brokerage in a Camel Route using AMQ_SCHEDULED_DELAY
Posted by Claus Ibsen <cl...@gmail.com>.
The NPE is because Camel need to introspect your bean and figure out
the best possible method to call
<to uri="bean:destinationConsumer" />
You can help Camel by specifying ?method=foo, to select the method to invoke.
Though we would like to fix the NPE. So if possible can you share the
code for this bean?
On Thu, Dec 20, 2012 at 6:34 AM, garrydias <ga...@gmail.com> wrote:
> http://pastie.org/5555839
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Howto use delay message brokerage in a Camel Route using
AMQ_SCHEDULED_DELAY
Posted by garrydias <ga...@gmail.com>.
Sure
here´s my applicationContext.xml:
http://pastie.org/5555839
thnx
--
View this message in context: http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5724418.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto use delay message brokerage in a Camel Route using AMQ_SCHEDULED_DELAY
Posted by Christian Müller <ch...@gmail.com>.
Please share your route "direct:routeToAmqDestination" with us.
Best,
Christian
On Wed, Dec 19, 2012 at 8:17 PM, garrydias <ga...@gmail.com> wrote:
> direct:routeToAmqDestination
--
Re: Howto use delay message brokerage in a Camel Route using
AMQ_SCHEDULED_DELAY
Posted by garrydias <ga...@gmail.com>.
Hello
I´m producing my scheduled messages but when AMQ push the message to
consumer I´m receiving this error:
(...)
[ ActiveMQ Task-1] FailoverTransport INFO
Successfully connected to tcp://localhost:61616
[ main] SpringCamelContext INFO Route:
route3 started and consuming from: Endpoint[activemq://destination]
[ main] SpringCamelContext INFO Total
3 routes, of which 3 is started.
[ main] SpringCamelContext INFO Apache
Camel 2.9.2 (CamelContext: camel-1) started in 0.776 seconds
*[4 - ErrorHandlerRedeliveryTask] DefaultErrorHandler ERROR
Failed delivery for (MessageId: ID:garrydell-50721-1355941463944-2:1:2:1:1
on ExchangeId: ID-garrydell-50722-1355941464309-0-3). Exhausted after
delivery attempt: 4 caught: java.lang.NullPointerException
java.lang.NullPointerException
at
org.apache.camel.component.bean.BeanInfo.chooseBestPossibleMethodInfo(BeanInfo.java:572)[camel-core-2.9.2.jar:2.9.2]
at
org.apache.camel.component.bean.BeanInfo.chooseMethodWithMatchingBody(BeanInfo.java:545)[camel-core-2.9.2.jar:2.9.2]*
(...)
- I already set schedulerSupport=true;
- Camel version: 2.9.2;
- AMQ version: 5.5.1 (but also happens in 5.6);
- producing line:
/template.sendBodyAndHeader("direct:routeToAmqDestination", "I´m sending my
message!", "AMQ_SCHEDULED_DELAY", "30000");/ (but also happens with cron
schedule and period schedule types);
- AMQ runs standalone;
- No AMQ configurations in my spring context xml wich have only some beans
and camelContext defined;
- Non scheduled messages are succesfully consumed.
Who knows why this error occurs?
Thanx
--
View this message in context: http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5724397.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto use delay message brokerage in a Camel Route using AMQ_SCHEDULED_DELAY
Posted by Christian Müller <ch...@gmail.com>.
Hello Claus!
Thanks for sharing this with us. I didn't was aware of this...
Best,
Christian
On Fri, Jan 6, 2012 at 1:39 PM, Claus Ibsen <cl...@gmail.com> wrote:
> On Thu, Jan 5, 2012 at 10:43 PM, Christian Müller
> <ch...@gmail.com> wrote:
> > Steven, Gert, did you could have a look at [1].
> >
> > I would like to work/support work on a specialized ActiveMQ error handler
> > which could like below (or similar):
> >
> > errorHandler(
> > activeMqDeadLetterChannel(activemq:queue:dlq)
> > .useOriginalMessage()
> > .maximumRedeliveries(8)
> > .deliveryDelay(60000)
> > .useExponentialBackOff()
> > .backOffMultiplier(2));
> >
> > It should use the ActiveMQ scheduled delay option to not have the
> messages
> > in flight when we have to wait for a new retry. What do you think?
> >
>
> ActiveMQ already have redelivery baked in.
>
> And from 5.6 onwards it support async non-blocked scheduled redelivery.
> https://issues.apache.org/jira/browse/AMQ-1853
>
>
>
> > [1]
> >
> camel.465427.n5.nabble.com/Missing-feature-to-handle-errors-in-a-route-which-reads-from-an-activemq-destination-td4416986.html
> >
> > Best,
> > Christian
> >
> > On Mon, Jan 2, 2012 at 1:06 PM, StevenD <
> steven.dehandtschutter@gmail.com>wrote:
> >
> >> Thanks, this was really helpful. I noticed however that the delay only
> >> worked
> >> for the first retry, all subsequent retries would be handled
> immediately. I
> >> solved this by resetting the scheduledJobId back to null just before
> >> sending
> >> it back to the queue. My exception handler now looks like:
> >>
> >> ...
> >> .onException(Exception.class)
> >> .handled(true)
> >> .beanRef("dispatchRetryTagger")
> >> .choice()
> >> .when(header("dispatchRetryCount").isLessThan(3))
> >> .setHeader("AMQ_SCHEDULED_DELAY", constant("4000"))
> >> .setHeader("scheduledJobId", constant(null))
> >> .to("activemq:queue:myqueue")
> >> .otherwise()
> >> .removeHeader("AMQ_SCHEDULED_DELAY")
> >> .to("direct:dlq")
> >> .end()
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5114568.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: Howto use delay message brokerage in a Camel Route using AMQ_SCHEDULED_DELAY
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jan 5, 2012 at 10:43 PM, Christian Müller
<ch...@gmail.com> wrote:
> Steven, Gert, did you could have a look at [1].
>
> I would like to work/support work on a specialized ActiveMQ error handler
> which could like below (or similar):
>
> errorHandler(
> activeMqDeadLetterChannel(activemq:queue:dlq)
> .useOriginalMessage()
> .maximumRedeliveries(8)
> .deliveryDelay(60000)
> .useExponentialBackOff()
> .backOffMultiplier(2));
>
> It should use the ActiveMQ scheduled delay option to not have the messages
> in flight when we have to wait for a new retry. What do you think?
>
ActiveMQ already have redelivery baked in.
And from 5.6 onwards it support async non-blocked scheduled redelivery.
https://issues.apache.org/jira/browse/AMQ-1853
> [1]
> camel.465427.n5.nabble.com/Missing-feature-to-handle-errors-in-a-route-which-reads-from-an-activemq-destination-td4416986.html
>
> Best,
> Christian
>
> On Mon, Jan 2, 2012 at 1:06 PM, StevenD <st...@gmail.com>wrote:
>
>> Thanks, this was really helpful. I noticed however that the delay only
>> worked
>> for the first retry, all subsequent retries would be handled immediately. I
>> solved this by resetting the scheduledJobId back to null just before
>> sending
>> it back to the queue. My exception handler now looks like:
>>
>> ...
>> .onException(Exception.class)
>> .handled(true)
>> .beanRef("dispatchRetryTagger")
>> .choice()
>> .when(header("dispatchRetryCount").isLessThan(3))
>> .setHeader("AMQ_SCHEDULED_DELAY", constant("4000"))
>> .setHeader("scheduledJobId", constant(null))
>> .to("activemq:queue:myqueue")
>> .otherwise()
>> .removeHeader("AMQ_SCHEDULED_DELAY")
>> .to("direct:dlq")
>> .end()
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5114568.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: Howto use delay message brokerage in a Camel Route using AMQ_SCHEDULED_DELAY
Posted by Christian Müller <ch...@gmail.com>.
Steven, Gert, did you could have a look at [1].
I would like to work/support work on a specialized ActiveMQ error handler
which could like below (or similar):
errorHandler(
activeMqDeadLetterChannel(activemq:queue:dlq)
.useOriginalMessage()
.maximumRedeliveries(8)
.deliveryDelay(60000)
.useExponentialBackOff()
.backOffMultiplier(2));
It should use the ActiveMQ scheduled delay option to not have the messages
in flight when we have to wait for a new retry. What do you think?
[1]
camel.465427.n5.nabble.com/Missing-feature-to-handle-errors-in-a-route-which-reads-from-an-activemq-destination-td4416986.html
Best,
Christian
On Mon, Jan 2, 2012 at 1:06 PM, StevenD <st...@gmail.com>wrote:
> Thanks, this was really helpful. I noticed however that the delay only
> worked
> for the first retry, all subsequent retries would be handled immediately. I
> solved this by resetting the scheduledJobId back to null just before
> sending
> it back to the queue. My exception handler now looks like:
>
> ...
> .onException(Exception.class)
> .handled(true)
> .beanRef("dispatchRetryTagger")
> .choice()
> .when(header("dispatchRetryCount").isLessThan(3))
> .setHeader("AMQ_SCHEDULED_DELAY", constant("4000"))
> .setHeader("scheduledJobId", constant(null))
> .to("activemq:queue:myqueue")
> .otherwise()
> .removeHeader("AMQ_SCHEDULED_DELAY")
> .to("direct:dlq")
> .end()
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Howto-use-delay-message-brokerage-in-a-Camel-Route-using-AMQ-SCHEDULED-DELAY-tp4282763p5114568.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>