SingleConnectionFactory - reconnection problem (AMQ Broker) #29115
Labels
in: messaging
Issues in messaging modules (jms, messaging)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
I have a problem with reconnection when
SingleConnectionFactory
(CachingConnectionFactory
) is used.I think it is a similar (or same?) problem reported in #23058 issue.
From all sources, which I have (logs, heap dump ...), it seems that problem is caused due missing Exception Listener
on connection (
ActiveMQConnection
), which is stored onSingleConnectionFactory
.I have following environment:
failover:(tcp://localhost:61616)?maxReconnectAttempts=5
SingleConnectionFactory
(CachingConnectionFactory
)setReconnectOnException(true)
Logs
CachingConnectionFactory
is invokedDefaultMessageListenerContainer
are presentCachingConnectionFactory
, but please stay with me for a moment (because I think the problem is inSingleConnectionFactory
)HeapDump
CachingConnectionFactory
SingleConnectionFactory$AggregatedExceptionListener
inaggregatedExceptionListener
ActiveMQConnection
underconnection
fieldexceptionListener
(onActiveMQConnection
) isnull
(ExceptionListener is missing - but this exception listener must be present to invoke reset of underlying JMS Connection stored onSingleConnectionFactory
)transportFailed
(onActiveMQConnection
) istrue
(it is a probably a reason why ExceptionListener is missing, see bellow)firstFailureError
(onActiveMQConnection
) isjava.net.UnknownHostException
(but type of the failure is not too important)Debugger
SingleConnectionFactory.initConnection()
Code (
SingleConnectionFactory.initConnection()
)Why ExceptionListener on JMS Connection stored on
SingleConnectionFactory
is missing?this.connection = doCreateConnection();
)prepareConnection(this.connection)
) throwsJMSException
SingleConnectionFactory
), but without JMS Exception ListenerSingleConnectionFactory.resetConnection()
is never invoked and "invalid" connection stays stored onSingleConnectionFactory
(till restart or "manual" invocation ofSingleConnectionFactory.resetConnection()
)I know it is (nearly) impossible to get this situation, because setup of exception listener (in
prepareConnection(Connection)
) should be (nearly) always done before invocation ofActiveMQConnection.onException(IOException)
method, which setstransportFailed
andfirstFailureError
, which finally caused thatActiveMQConnection.setExceptionListener(ExceptionListener)
(invoked inprepareConnection(this.connection)
) throwsConnectionFailedException
, but I see this state in application heap dump (I am sorry).My proposal is to change
SingleConnectionFactory.initConnection()
in a way, when new connection is created and configured/prepared in method local field and when all is ok, then assign it to instance connection field. Something like this:The text was updated successfully, but these errors were encountered: