From ce7495ec1e613fe878ecef7f539ca0f004484269 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Tue, 15 Apr 2008 13:40:10 +0000 Subject: [PATCH] Avoid the ugly 'Async exception with no exception listener' message from showing up in the output when shutting down the broker. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@648250 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/ActiveMQConnection.java | 2 +- .../org/apache/activemq/broker/util/CommandAgent.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java index 64859813b4..4fdcab094e 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java @@ -1692,7 +1692,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon }); } else { - LOG.warn("Async exception with no exception listener: " + error, error); + LOG.debug("Async exception with no exception listener: " + error, error); } } } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java index 484a9b0dab..5f7bba6cf0 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/CommandAgent.java @@ -19,6 +19,7 @@ package org.apache.activemq.broker.util; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; +import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Session; @@ -39,7 +40,7 @@ import org.springframework.beans.factory.InitializingBean; * @version $Revision$ * @org.apache.xbean.XBean */ -public class CommandAgent implements Service, InitializingBean, DisposableBean, FactoryBean { +public class CommandAgent implements Service, InitializingBean, DisposableBean, FactoryBean, ExceptionListener { private static final Log LOG = LogFactory.getLog(CommandAgent.class); private String brokerUrl = "vm://localhost"; @@ -137,6 +138,7 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, public Connection getConnection() throws JMSException { if (connection == null) { connection = createConnection(); + connection.setExceptionListener(this); connection.start(); } return connection; @@ -164,4 +166,11 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean, protected Destination createCommandDestination() { return AdvisorySupport.getAgentDestination(); } + + public void onException(JMSException exception) { + try { + stop(); + } catch (Exception e) { + } + } }