activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r918384 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ActiveMQConnectionFactory.java test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
Date Wed, 03 Mar 2010 10:28:54 GMT
Author: gtully
Date: Wed Mar  3 10:28:54 2010
New Revision: 918384

URL: http://svn.apache.org/viewvc?rev=918384&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2635

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java?rev=918384&r1=918383&r2=918384&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Wed Mar  3 10:28:54 2010
@@ -115,6 +115,7 @@
     private int auditMaximumProducerNumber = ActiveMQMessageAudit.MAXIMUM_PRODUCER_COUNT;
     private boolean useDedicatedTaskRunner;
     private long consumerFailoverRedeliveryWaitPeriod = 0;
+    private ClientInternalExceptionListener clientInternalExceptionListener;
 
     // /////////////////////////////////////////////
     //
@@ -323,6 +324,9 @@
         if (exceptionListener != null) {
         	connection.setExceptionListener(exceptionListener);
         }
+        if (clientInternalExceptionListener != null) {
+            connection.setClientInternalExceptionListener(clientInternalExceptionListener);
+        }
     }
 
     // /////////////////////////////////////////////
@@ -923,4 +927,22 @@
     public long getConsumerFailoverRedeliveryWaitPeriod() {
         return consumerFailoverRedeliveryWaitPeriod;
     }
+
+    public ClientInternalExceptionListener getClientInternalExceptionListener() {
+        return clientInternalExceptionListener;
+    }
+    
+    /**
+     * Allows an {@link ClientInternalExceptionListener} to be configured on the ConnectionFactory
so that when this factory
+     * is used by frameworks which don't expose the Connection such as Spring JmsTemplate,
you can register
+     * an exception listener.
+     * <p> Note: access to this clientInternalExceptionListener will <b>not</b>
be serialized if it is associated with more than
+     * on connection (as it will be if more than one connection is subsequently created by
this connection factory)
+     * @param clientInternalExceptionListener sets the exception listener to be registered
on all connections
+     * created by this factory
+     */
+    public void setClientInternalExceptionListener(
+            ClientInternalExceptionListener clientInternalExceptionListener) {
+        this.clientInternalExceptionListener = clientInternalExceptionListener;
+    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java?rev=918384&r1=918383&r2=918384&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
Wed Mar  3 10:28:54 2010
@@ -30,7 +30,6 @@
 import org.apache.activemq.broker.BrokerRegistry;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -184,6 +183,29 @@
         
     }
 
+    
+    public void testSetClientInternalExceptionListener() throws Exception {
+        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+        connection = (ActiveMQConnection)cf.createConnection();
+        assertNull(connection.getClientInternalExceptionListener());
+        
+        ClientInternalExceptionListener listener = new ClientInternalExceptionListener()
{
+            public void onException(Throwable exception) {
+            }
+        };
+        connection.setClientInternalExceptionListener(listener);
+        cf.setClientInternalExceptionListener(listener);
+        
+        connection = (ActiveMQConnection)cf.createConnection();
+        assertNotNull(connection.getClientInternalExceptionListener());
+        assertEquals(listener, connection.getClientInternalExceptionListener());
+        
+        connection = (ActiveMQConnection)cf.createConnection();
+        assertEquals(listener, connection.getClientInternalExceptionListener());   
+        assertEquals(listener, cf.getClientInternalExceptionListener());
+        
+    }
+
     protected void assertCreateConnection(String uri) throws Exception {
         // Start up a broker with a tcp connector.
         broker = new BrokerService();



Mime
View raw message