本文整理汇总了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;
}