org.apache.activemq.ActiveMQConnectionFactory.setExceptionListener()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.activemq.ActiveMQConnectionFactory.setExceptionListener()方法的一些代码示例,展示了ActiveMQConnectionFactory.setExceptionListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.setExceptionListener()方法的具体详情如下:
包路径:org.apache.activemq.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:setExceptionListener

ActiveMQConnectionFactory.setExceptionListener介绍

[英]Allows an 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.

Note: access to this exceptionLinstener will not 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)
[中]允许在ConnectionFactory上配置ExceptionListener,以便在不公开连接的框架(如Spring JmsTemplate)使用此工厂时,可以注册异常侦听器。
注意:如果此ExceptionInstener与多个on连接关联,则不会序列化对此ExceptionInstener的访问(如果此连接工厂随后创建了多个连接,则不会序列化)

代码示例

代码示例来源:origin: apache/activemq-artemis

protected ConnectionFactory getConnectionFactory() throws Exception {
 factory.setExceptionListener(new ExceptionListener() {
   @Override
   public void onException(JMSException arg0) {
    if (arg0 instanceof ResourceAllocationException) {
      gotResourceException.set(true);
    }
   }
 });
 return factory;
}

代码示例来源:origin: apache/activemq-artemis

@Test
public void testPublisherRecoverAfterBlockWithSyncSend() throws Exception {
 ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) getConnectionFactory();
 factory.setExceptionListener(null);
 factory.setUseAsyncSend(false);
 this.flowControlConnection = (ActiveMQConnection) factory.createConnection();

代码示例来源:origin: de.taimos/dvalin-interconnect-core

/**
 * @param brokerUrl the URL of the Interconnect message broker
 * @throws InfrastructureException of connection error
 */
public static void start(final String brokerUrl) throws InfrastructureException {
  if (MessageConnector.started.compareAndSet(false, true)) {
    try {
      final ActiveMQConnectionFactory mqFactory = new ActiveMQConnectionFactory(brokerUrl);
      mqFactory.setExceptionListener(MessageConnector.createMqErrorListener());
      // Set up message queue connection.
      MessageConnector.pooledConnectionFactory = new PooledConnectionFactory(mqFactory);
      MessageConnector.pooledConnectionFactory.setCreateConnectionOnStartup(true);
      MessageConnector.pooledConnectionFactory.setIdleTimeout(0);
      MessageConnector.pooledConnectionFactory.setMaxConnections(3);
      MessageConnector.pooledConnectionFactory.setMaximumActiveSessionPerConnection(100);
      MessageConnector.pooledConnectionFactory.setTimeBetweenExpirationCheckMillis(30000);
      MessageConnector.pooledConnectionFactory.setBlockIfSessionPoolIsFull(false);
      // Start the pooled connection factory.
      MessageConnector.pooledConnectionFactory.start();
    } catch (final Exception e) {
      throw new InfrastructureException(MessageConnector.CONNECTION_START_FAIL, e);
    }
  }
}

相关文章

微信公众号

最新文章

更多

ActiveMQConnectionFactory类方法