当前位置: 首页>>代码示例>>Java>>正文


Java ActiveMQConnection.addTransportListener方法代码示例

本文整理汇总了Java中org.apache.activemq.ActiveMQConnection.addTransportListener方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQConnection.addTransportListener方法的具体用法?Java ActiveMQConnection.addTransportListener怎么用?Java ActiveMQConnection.addTransportListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.ActiveMQConnection的用法示例。


在下文中一共展示了ActiveMQConnection.addTransportListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Worker

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
public Worker(final String name) throws URISyntaxException, JMSException {
   this.name = name;
   URI uri = new URI("failover://(mock://(" + tcpUri + "))?updateURIsSupported=false");
   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(uri);
   connection = (ActiveMQConnection) factory.createConnection();
   connection.addTransportListener(new TransportListener() {
      @Override
      public void onCommand(Object command) {
      }

      @Override
      public void onException(IOException error) {
         setError(error);
      }

      @Override
      public void transportInterupted() {
         LOG.info("Worker " + name + " was interrupted...");
         interruptedCount.incrementAndGet();
      }

      @Override
      public void transportResumed() {
         LOG.info("Worker " + name + " was resummed...");
         resumedCount.incrementAndGet();
      }
   });
   connection.start();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:30,代码来源:ReconnectTest.java

示例2: createConnection

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private final Connection createConnection() throws JMSException
{
	final ActiveMQConnection conn = (ActiveMQConnection)getConnectionFactory().createConnection();

	conn.setExceptionListener(exceptionListener);
	conn.addTransportListener(transportListener);

	//
	// Set ClientID
	final String clientID = getClientID();
	if (conn.getClientID() == null)
	{
		conn.setClientID(clientID);
	}
	else
	{
		if (conn.getClientID().equals(clientID))
		{
			throw new AdempiereException("Connection with clientID '" + clientID + "' already exists");
		}
		else
		{
			conn.setClientID(clientID);
		}
	}

	//
	// Start the connection
	conn.start();

	logger.info("Connection created and started: {}", conn);
	return conn;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:ActiveMQJMSEndpoint.java


注:本文中的org.apache.activemq.ActiveMQConnection.addTransportListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。