resolve AMQ-2062 - add setExceptionListener to amq connection factory -

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@733811 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-01-12 15:48:07 +00:00
parent 0b34f3c89f
commit 8b9e755035
1 changed files with 24 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import java.util.concurrent.ThreadFactory;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
@ -110,6 +111,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
private int sendTimeout =0;
private boolean sendAcksAsync=true;
private TransportListener transportListener;
private ExceptionListener exceptionListener;
// /////////////////////////////////////////////
//
@ -286,7 +288,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
return connection;
}
protected void configureConnection(ActiveMQConnection connection) {
protected void configureConnection(ActiveMQConnection connection) throws JMSException {
connection.setPrefetchPolicy(getPrefetchPolicy());
connection.setDisableTimeStampsByDefault(isDisableTimeStampsByDefault());
connection.setOptimizedMessageDispatch(isOptimizedMessageDispatch());
@ -311,6 +313,9 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
if (transportListener != null) {
connection.addTransportListener(transportListener);
}
if (exceptionListener != null) {
connection.setExceptionListener(exceptionListener);
}
}
// /////////////////////////////////////////////
@ -859,4 +864,22 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
public void setTransportListener(TransportListener transportListener) {
this.transportListener = transportListener;
}
public ExceptionListener getExceptionListener() {
return exceptionListener;
}
/**
* Allows an {@link ExceptionListener} 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 exceptionLinstener 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 exceptionListener sets the exception listener to be registered on all connections
* created by this factory
*/
public void setExceptionListener(ExceptionListener exceptionListener) {
this.exceptionListener = exceptionListener;
}
}