本文整理了Java中javax.jms.Connection.getExceptionListener()
方法的一些代码示例,展示了Connection.getExceptionListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.getExceptionListener()
方法的具体详情如下:
包路径:javax.jms.Connection
类名称:Connection
方法名:getExceptionListener
[英]Gets the ExceptionListener object for this connection. Not every Connection has an ExceptionListenerassociated with it.
[中]获取此连接的ExceptionListener对象。并非每个连接都有与之相关的例外情况。
代码示例来源:origin: openzipkin/brave
@Override public ExceptionListener getExceptionListener() throws JMSException {
return delegate.getExceptionListener();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testWithConnectionFactoryAndExceptionListener() throws JMSException {
ConnectionFactory cf = mock(ConnectionFactory.class);
Connection con = mock(Connection.class);
ExceptionListener listener = new ChainedExceptionListener();
given(cf.createConnection()).willReturn(con);
given(con.getExceptionListener()).willReturn(listener);
SingleConnectionFactory scf = new SingleConnectionFactory(cf);
scf.setExceptionListener(listener);
Connection con1 = scf.createConnection();
assertEquals(listener, con1.getExceptionListener());
con1.start();
con1.stop();
con1.close();
Connection con2 = scf.createConnection();
con2.start();
con2.stop();
con2.close();
scf.destroy(); // should trigger actual close
verify(con).setExceptionListener(listener);
verify(con, times(2)).start();
verify(con, times(2)).stop();
verify(con).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testWithConnectionFactoryAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock(ConnectionFactory.class);
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
SingleConnectionFactory scf = new SingleConnectionFactory(cf);
scf.setReconnectOnException(true);
Connection con1 = scf.createConnection();
assertNull(con1.getExceptionListener());
con1.start();
con.getExceptionListener().onException(new JMSException(""));
Connection con2 = scf.createConnection();
con2.start();
scf.destroy(); // should trigger actual close
assertEquals(2, con.getStartCount());
assertEquals(2, con.getCloseCount());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock(ConnectionFactory.class);
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
TestExceptionListener listener = new TestExceptionListener();
SingleConnectionFactory scf = new SingleConnectionFactory(cf);
scf.setExceptionListener(listener);
scf.setReconnectOnException(true);
Connection con1 = scf.createConnection();
assertSame(listener, con1.getExceptionListener());
con1.start();
con.getExceptionListener().onException(new JMSException(""));
Connection con2 = scf.createConnection();
con2.start();
scf.destroy(); // should trigger actual close
assertEquals(2, con.getStartCount());
assertEquals(2, con.getCloseCount());
assertEquals(1, listener.getCount());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException {
ConnectionFactory cf = mock(ConnectionFactory.class);
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
TestExceptionListener listener0 = new TestExceptionListener();
TestExceptionListener listener1 = new TestExceptionListener();
TestExceptionListener listener2 = new TestExceptionListener();
SingleConnectionFactory scf = new SingleConnectionFactory(cf);
scf.setReconnectOnException(true);
scf.setExceptionListener(listener0);
Connection con1 = scf.createConnection();
con1.setExceptionListener(listener1);
assertSame(listener1, con1.getExceptionListener());
con1.start();
Connection con2 = scf.createConnection();
con2.setExceptionListener(listener2);
assertSame(listener2, con2.getExceptionListener());
con.getExceptionListener().onException(new JMSException(""));
con2.close();
con1.getMetaData();
con.getExceptionListener().onException(new JMSException(""));
con1.close();
scf.destroy(); // should trigger actual close
assertEquals(2, con.getStartCount());
assertEquals(2, con.getCloseCount());
assertEquals(2, listener0.getCount());
assertEquals(2, listener1.getCount());
assertEquals(1, listener2.getCount());
}
代码示例来源:origin: spring-projects/spring-framework
Connection con1 = scf.createConnection();
con1.setExceptionListener(listener1);
assertSame(listener1, con1.getExceptionListener());
Connection con2 = scf.createConnection();
con2.setExceptionListener(listener2);
assertSame(listener2, con2.getExceptionListener());
con.getExceptionListener().onException(new JMSException(""));
con2.close();
代码示例来源:origin: bitronix/btm
@Override
public ExceptionListener getExceptionListener() throws JMSException {
return nonXaConnection.getExceptionListener();
}
代码示例来源:origin: org.apache.openejb/openejb-core
@Override
public ExceptionListener getExceptionListener() throws JMSException {
return con.getExceptionListener();
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
@Override
public ExceptionListener getExceptionListener() throws JMSException {
return nonXaConnection.getExceptionListener();
}
代码示例来源:origin: com.bbossgroups.rpc/bboss-rpc
public ExceptionListener getExceptionListener() throws JMSException
{
// TODO Auto-generated method stub
return con.getExceptionListener();
}
代码示例来源:origin: org.codehaus.btm/btm
public ExceptionListener getExceptionListener() throws JMSException {
return nonXaConnection.getExceptionListener();
}
代码示例来源:origin: com.axway.ats.framework/ats-actionlibrary
@Override
public ExceptionListener getExceptionListener() throws JMSException {
return connection.getExceptionListener();
}
代码示例来源:origin: org.mule.btm/mule-btm
public ExceptionListener getExceptionListener() throws JMSException {
return nonXaConnection.getExceptionListener();
}
代码示例来源:origin: sk.seges.sesam/sesam-remote
/**
* Custom JMS exception handler if default isn't sufficient. Default handler is just logging the exception.
* @param listener
* @throws JMSException
* @see {@link Connection#setExceptionListener(ExceptionListener)}
*/
public void setJMSExceptionListener(ExceptionListener listener) throws JMSException {
this.exceptionListener = listener;
if(connection != null && !connection.getExceptionListener().equals(listener)) {
// set it for existing connection, for non-existing it is set in startListening
connection.setExceptionListener(listener);
}
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public ExceptionListener getExceptionListener() {
try {
return connection().getExceptionListener();
} catch (final JMSException e) {
throw toRuntimeException(e);
}
}
代码示例来源:origin: skyscreamer/nevado
private boolean processMessage(NevadoMessageConsumer consumer) {
boolean messageProcessed = false;
if (consumer.getMessageListener() != null) {
try {
if (consumer.processAsyncMessage()) {
messageProcessed = true;
}
} catch (Throwable t) {
String errorMessage = "Unable to process message for consumer on " + consumer.getDestination();
_log.error(errorMessage, t);
ExceptionListener exceptionListener = null;
try {
exceptionListener = _connection.getExceptionListener();
} catch (JMSException e1) {
_log.error("Unable to retrieve exception listener from connection", e1);
}
if (exceptionListener != null)
{
JMSException e = (t instanceof JMSException) ? (JMSException)t
: new JMSException(errorMessage + ": " + t.getMessage());
exceptionListener.onException(e);
}
}
}
return messageProcessed;
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testSetClientIdAfterGetExceptionListener() throws Exception {
Connection conn = cf.createConnection();
conn.getExceptionListener();
conn.setClientID("clientId");
conn.close();
}
代码示例来源:origin: org.seedstack.addons.jms/jms-core
messagePoller.setExceptionListener((ExceptionListener) connection);
} else {
messagePoller.setExceptionListener(connection.getExceptionListener());
代码示例来源:origin: org.seedstack.addons.jms/jms
messagePoller.setExceptionListener((ExceptionListener) connection);
} else {
messagePoller.setExceptionListener(connection.getExceptionListener());
代码示例来源:origin: apache/activemq-artemis
ExceptionListener listener2 = conn.getExceptionListener();
ExceptionListener listener = connection.getExceptionListener();
try {
connection.setClientID(clientID);
内容来源于网络,如有侵权,请联系作者删除!