當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。