Hopefully this is the correct place for this post, not sure if it should be under Camel or ActiveMQ. Searching has not given a clear answer to our problem.
Our exception involves a server invoking ProducerTemplate.sendBody() to send a message to ActiveMQ on another server that is down. We want to handle this error gracefully with retry logic allowing time for the server to be started. We have tried many variations on the following with no success. Using Camel errorHandler and onException globally have not been triggered, and onException within a specific Camel route definition has not been triggered. Also attempted jms.redeliveryPolicy properties on the ActiveMQComponent bean brokerURL with no effect. Using a try/catch block around the ProducerTemplate.sendBody() call in the java code was the only place where we were able to catch this error, but we would prefer to configure the error handling in the xml with the route or bean configuration. Can we use the error handling configuration in the xml to deal with this or must it be handled in the java code? If we can use the xml is there a good example of this somewhere? Thanks! Stack trace below: 12-11 11:33:24.009 [ null_THREAD] ThreadController ERROR run: controllerName=null_THREAD org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[...] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1368) at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:622) at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467) at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:463) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:144) at com.mpower.pro.as.eventcontroller.DeployedStrategyEventController.sendDeployedStrategy(DeployedStrategyEventController.java:94) at com.mpower.pro.as.eventcontroller.DeployedStrategyEventController.run(DeployedStrategyEventController.java:173) at com.mpower.pro.core.controller.ThreadController.run(ThreadController.java:157) at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:8882. Reason: java.net.ConnectException: Connection refused: connect at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316) at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:496) at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:228) at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:421) at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:375) at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:151) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73) at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378) at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346) at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242) at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346) at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184) at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137) ... 5 more Caused by: javax.jms.JMSException: Error while attempting to add new Connection to the pool at org.apache.activemq.jms.pool.PooledConnectionFactory.createJmsException(PooledConnectionFactory.java:243) at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:198) at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:177) at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:483) ... 18 more Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:8882. Reason: java.net.ConnectException: Connection refused: connect at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:358) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:303) at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:243) at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:251) at org.apache.activemq.jms.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:98) at org.apache.activemq.jms.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:78) at org.apache.commons.pool.impl.GenericKeyedObjectPool.addObject(GenericKeyedObjectPool.java:1668) at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:196) ... 21 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:501) at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:464) at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55) at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:138) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:338) ... 28 more -- View this message in context: http://camel.465427.n5.nabble.com/How-to-handle-CamelExecutionException-for-ActiveMQ-tp5760589.html Sent from the Camel Development mailing list archive at Nabble.com.