Hello,

I am using netty to connect to a server (over SSL). It is mostly working
well.
Unfortunately though the server appears to kill the connection after an
unspecified period of inactivity. I see exceptions from netty, which is
fine, but I don't see any attempt to reconnect
(I currently have to restart my process to reconnect to the server).

What is the right way to handle this scenario? Is it the applications
responsibility to somehow restart netty (by stopping/restarting the route on
receiving a specific exception)? Or should CAMEL/Netty
be automatically reconnecting?

If someone could give me an idea on how to handle this scenario it would be
much appreciated.

thanks very much in advance,
Gareth Collins

Sequence Of Events (removed/replaced my irrelevant class/IP address/queue
names in trace):

(1) Exception from netty indicating connection is lost:

2010-05-05 18:49:36,560::DEBUG: Endpoint[activemq://xxx.yyy] consumer
receiving JMS message: ActiveMQObjectMessage {commandId = 5,
responseRequired = true, messageId =
ID:dev02-44105-1273011264197-2:69:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:dev02-44105-1273011264197-2:69:1:1, destination = queue://xxx.yyy,
transactionId = null, expiration = 0, timestamp = 1273099776544, arrival =
0, brokerInTime = 1273099776544, brokerOutTime = 1273099776550,
correlationId = null, replyTo = null, persistent = true, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content =
org.apache.activemq.util.byteseque...@218d, marshalledProperties =
org.apache.activemq.util.byteseque...@9ac272, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {CamelJmsDeliveryMode=2},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
2010-05-05 18:49:36,561::INFO : ID:dev02-44105-1273011264197-2:69:1:1:1 >>>
(route1) from(activemq://xxx.yyy) --> tcp://aa.bb.cc.dd:1234 <<<
Pattern:InOnly, Headers:{JMSPriority=4, JMSRedelivered=false,
JMSExpiration=0, JMSXGroupID=null, CamelJmsDeliveryMode=2,
JMSMessageID=ID:dev02-44105-1273011264197-2:69:1:1:1,
JMSDestination=queue://xxx.yyy, JMSReplyTo=null, JMSTimestamp=1273099776544,
JMSCorrelationID=null, JMSDeliveryMode=2, JMSType=null}, BodyType:<hidden>,
Body:<hidden>
2010-05-05 18:49:36,573::DEBUG: An exception was caught by the
ClientChannelHandler during communication
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcher.read0(Native Method) ~[na:1.6.0_11]
        at sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[na:1.6.0_11]
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[na:1.6.0_11]
        at sun.nio.ch.IOUtil.read(Unknown Source) ~[na:1.6.0_11]
        at sun.nio.ch.SocketChannelImpl.read(Unknown Source) ~[na:1.6.0_11]
        at
org.jboss.netty.buffer.HeapChannelBuffer.setBytes(HeapChannelBuffer.java:156)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.buffer.AbstractChannelBuffer.writeBytes(AbstractChannelBuffer.java:425)
~[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:305)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:275)
~[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:196)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
[netty-3.1.5.GA.jar:na]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown 
Source)
[na:1.6.0_11]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[na:1.6.0_11]
        at java.lang.Thread.run(Unknown Source) [na:1.6.0_11]

(2) Another try to send:

2010-05-05 18:50:16,645::DEBUG: Endpoint[activemq://xxx.yyy] consumer
receiving JMS message: ActiveMQObjectMessage {commandId = 5,
responseRequired = true, messageId =
ID:dev02-44105-1273011264197-2:70:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:dev02-44105-1273011264197-2:70:1:1, destination = queue://xxx.yyy,
transactionId = null, expiration = 0, timestamp = 1273099816628, arrival =
0, brokerInTime = 1273099816628, brokerOutTime = 1273099816634,
correlationId = null, replyTo = null, persistent = true, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content =
org.apache.activemq.util.byteseque...@1ddcac5, marshalledProperties =
org.apache.activemq.util.byteseque...@2b7fc2, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {CamelJmsDeliveryMode=2},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
2010-05-05 18:50:16,647::INFO : ID:dev02-44105-1273011264197-2:70:1:1:1 >>>
(route1) from(activemq://xxx.yyy) --> tcp://aa.bb.cc.dd:1234 <<<
Pattern:InOnly, Headers:{JMSDeliveryMode=2, JMSDestination=queue://xxx.yyy,
JMSRedelivered=false, CamelJmsDeliveryMode=2,
JMSMessageID=ID:dev02-44105-1273011264197-2:70:1:1:1, JMSType=null,
JMSTimestamp=1273099816628, JMSPriority=4, JMSXGroupID=null,
JMSReplyTo=null, JMSCorrelationID=null, JMSExpiration=0}, BodyType:<hidden>,
Body:<hidden>
2010-05-05 18:50:16,652::DEBUG: An exception was caught by the
ClientChannelHandler during communication
java.nio.channels.ClosedChannelException: null
        at
org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:630)
~[netty-3.1.5.GA.jar:na]
        at 
org.jboss.netty.channel.socket.nio.NioWorker.write(NioWorker.java:346)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:117)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.handler.ssl.SslHandler.flushPendingEncryptedWrites(SslHandler.java:659)
~[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.handler.ssl.SslHandler.wrap(SslHandler.java:596)
~[netty-3.1.5.GA.jar:na]
        at
org.jboss.netty.handler.ssl.SslHandler.handleDownstream(SslHandler.java:385)
~[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.channel.Channels.write(Channels.java:916)
[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.channel.Channels.write(Channels.java:857)
[netty-3.1.5.GA.jar:na]
        at MyEncoder.writeRequested(Unknown Source) ~[MyEncoder.jar:na]
        at org.jboss.netty.channel.Channels.write(Channels.java:895)
[netty-3.1.5.GA.jar:na]
        at org.jboss.netty.channel.Channels.write(Channels.java:842)
[netty-3.1.5.GA.jar:na]
        at 
org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:229)
[netty-3.1.5.GA.jar:na]
        at
org.apache.camel.component.netty.NettyProducer.process(NettyProducer.java:88)
[camel-netty-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:106)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:103)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:189)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:103)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:87)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:173)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
[camel-core-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:84)
[camel-jms-2.3-SNAPSHOT.jar:2.3-SNAPSHOT]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:559)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1002)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:994)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:896)
[org.springframework.jms-3.0.2.RELEASE.jar:3.0.2.RELEASE]
        at java.lang.Thread.run(Unknown Source) [na:1.6.0_11]

(3) Third try - no error but the message doesn't get sent (no connection to
the server)!!

2010-05-05 19:00:36,684::DEBUG: Received message of type [class
org.apache.activemq.command.ActiveMQObjectMessage] from consumer
[ActiveMQMessageConsumer { value=ID:dev02-59760-1273084358691-0:0:1:1,
started=true }] of session [PooledSession { ActiveMQSession
{id=ID:dev02-59760-1273084358691-0:0:1,started=true} }]
2010-05-05 19:00:36,703::DEBUG: Endpoint[activemq://xxx.yyy] consumer
receiving JMS message: ActiveMQObjectMessage {commandId = 5,
responseRequired = true, messageId =
ID:dev02-44105-1273011264197-2:71:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:dev02-44105-1273011264197-2:71:1:1, destination = queue://xxx.yyy,
transactionId = null, expiration = 0, timestamp = 1273100436654, arrival =
0, brokerInTime = 1273100436655, brokerOutTime = 1273100436672,
correlationId = null, replyTo = null, persistent = true, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content =
org.apache.activemq.util.byteseque...@12801c5, marshalledProperties =
org.apache.activemq.util.byteseque...@18c668c, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {CamelJmsDeliveryMode=2},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
2010-05-05 19:00:36,706::INFO : ID:dev02-44105-1273011264197-2:71:1:1:1 >>>
(route1) from(activemq://xxx.yyy) --> tcp://aa.bb.cc.dd:1234 <<<
Pattern:InOnly, Headers:{JMSPriority=4, JMSDestination=queue://xxx.yyy,
JMSType=null, JMSXGroupID=null, JMSCorrelationID=null,
JMSTimestamp=1273100436654, JMSDeliveryMode=2, CamelJmsDeliveryMode=2,
JMSRedelivered=false, JMSExpiration=0, JMSReplyTo=null,
JMSMessageID=ID:dev02-44105-1273011264197-2:71:1:1:1}, BodyType:<hidden>,
Body:<hidden>
-- 
View this message in context: 
http://old.nabble.com/Recovery-From-Netty-Connection-Drop-tp28467631p28467631.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to