本文整理匯總了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();
}
示例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;
}