The OnException method of registered Exception listener is not called in when
broker is stopped.
------------------------------------------------------------------------------------------------
Key: AMQCPP-323
URL: https://issues.apache.org/activemq/browse/AMQCPP-323
Project: ActiveMQ C++ Client
Issue Type: Bug
Affects Versions: 3.2.3, 3.2.2, 3.2.1, 3.2.0
Environment: Windows
Reporter: Hal Henderson
Assignee: Timothy Bish
In order to reconnect when the broker is stopped, our application registers an
exception listener by calling ActiveMQConnection::setExceptionListener.
Previously, we used activemq-cpp 3.0.1 which would call our applications
onException method whenever the broker was stopped. Our onException method
cleans up the connection and attempts create a new connection until it is
successful. This worked fine with activemq-cpp 3.0.1.
We recently changed our application to use activemq-cpp 3.2.2. We found that
with this version of activemq-cpp (and no changes to our application) our
onException method is not called when the broker is stopped. The result is
that our application can not send or receive any message without restarting the
application.
We debugged the problem and found that in the class ConnectionConfig
(ActiveMQConnection.cpp) there are two cms::ExceptionListener instance
variables: defaultListener and exceptionListener. The method
ActiveMQConnection::setExceptionListener sets defaultListener to the input
listener object. However, the method ActiveMQConnection::fire calls the
onException method of exceptionListener (if it is not NULL). As far as I
could see there is no way for exceptionListener to be set to anything but NULL.
The fix proposed fix is to remove defaultListener and to replace all uses of
defaultListener with exceptionListener. After making the proposed change, the
OnException method is getting called as expected.
The diff of ActiveMQConnection.cpp are as follows:
ActiveMQConnection.cpp
@@ -109,7 +109,6 @@
unsigned int closeTimeout;
unsigned int producerWindowSize;
- cms::ExceptionListener* defaultListener;
std::auto_ptr<PrefetchPolicy> defaultPrefetchPolicy;
std::auto_ptr<RedeliveryPolicy> defaultRedeliveryPolicy;
@@ -130,7 +129,6 @@
sendTimeout( 0 ),
closeTimeout( 15000 ),
producerWindowSize( 0 ),
- defaultListener( NULL ),
defaultPrefetchPolicy( NULL ),
defaultRedeliveryPolicy( NULL ),
exceptionListener( NULL ) {
@@ -965,12 +963,12 @@
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConnection::setExceptionListener( cms::ExceptionListener*
listener ) {
- this->config->defaultListener = listener;
+ this->config->exceptionListener = listener;
}
////////////////////////////////////////////////////////////////////////////////
cms::ExceptionListener* ActiveMQConnection::getExceptionListener() const {
- return this->config->defaultListener;
+ return this->config->exceptionListener;
}
////////////////////////////////////////////////////////////////////////////////
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.