camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: How to handle success/failure when sending async InOnly to JMS?
Date Sat, 21 Apr 2012 14:05:08 GMT
On Thu, Apr 19, 2012 at 12:27 PM, Brook, James <> wrote:
> I have a producer in a request handling thread that I am using to send messages to a
remote JMS (ActiveMQ) broker. I am using the asycSendBody method on the producerTemplate.
I discovered that if the broker goes down the producer starts to block. I can't afford for
the producer ever to block, so I have added an ExecutorService using a short queue and the
'Discard' policy. Here is the root that I have:

You can configure AMQ client to use syncSend then it will fail faster
if the broker goes down.

> from("direct:tuneStart")
>    .threads(5, 20).maxQueueSize(5).rejectedPolicy(ThreadPoolRejectedPolicy.Discard)
>    .to("jms:queue:myQueue?jmsMessageType=Text")
> Now my producer never blocks. However, I do want to gather metrics or log successful
versus failed events. I don't want to do that in the producer though.
> I seem to have two sorts of failure:
> 1. I use the ActiveMQ failover transport with a timeout of 1 second. When the broker
is down I see the messages that get onto the queue fail after one second with an 'uncategorized'
JMSException [1].
> 2. When the queues fill up the messages are silently discarded. I know I could also use
the Abort policy.
> I want to have a handler for every successful message and for each type of failure. Can
anyone tell me how to do this please? Can I use Camel exception clause (onException). Or do
I somehow have to introduce a bean with an exchange that can handle futures? Is 'onCompletion'
useful here?
> Any help would be very much appreciated. I have only just started using Camel. Thank
> James
> org.apache.activemq.transport.failover.FailoverTransport  - Failover timed out after
> [1] Failed delivery for (MessageId: ID-james-xxxx-52220-1334830271190-0-5 on ExchangeId:
ID-james-xxxx-52220-1334830271190-0-6). Exhausted after delivery attempt: 1 caught: org.springframework.jms.UncategorizedJmsException:
Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException:
Failover timeout of 1000 ms reached.
> IOException: Failover timeout of 1000 ms reached.
>  at org.apache.activemq.transport.failover.FailoverTransport.oneway(
>  at org.apache.activemq.transport.MutexTransport.oneway(
>  at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(
>  at org.apache.activemq.transport.ResponseCorrelator.request(
>  at org.apache.activemq.ActiveMQConnection.syncSendPacket(
>  at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(
>  at org.apache.activemq.ActiveMQConnection.createSession(
>  at
>  at org.springframework.jms.core.JmsTemplate.execute(
>  at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(
>  at org.apache.camel.component.jms.JmsProducer.doSend(
>  at org.apache.camel.component.jms.JmsProducer.processInOnly(
>  at org.apache.camel.component.jms.JmsProducer.process(
>  at org.apache.camel.util.AsyncProcessorHelper.process(
>  at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(
>  ….

Claus Ibsen
CamelOne 2012 Conference, May 15-16, 2012:
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message