本文整理了Java中org.apache.activemq.ActiveMQConnectionFactory.setTransportListener()
方法的一些代码示例,展示了ActiveMQConnectionFactory.setTransportListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActiveMQConnectionFactory.setTransportListener()
方法的具体详情如下:
包路径:org.apache.activemq.ActiveMQConnectionFactory
类名称:ActiveMQConnectionFactory
方法名:setTransportListener
[英]Allows a listener to be configured on the ConnectionFactory so that when this factory is used with frameworks which don't expose the Connection such as Spring JmsTemplate, you can still register a transport listener.
[中]允许在ConnectionFactory上配置侦听器,以便当此工厂与不公开连接的框架(如Spring JmsTemplate)一起使用时,您仍然可以注册传输侦听器。
代码示例来源:origin: stackoverflow.com
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
// set transport listener so that active MQ start is notified.
factory.setTransportListener(transportListenerObject);
Connection connection = factory.createConnection();
// This will throw error if activeMQ is not running.
connection.setClientID("my_client_id");
} catch (JMSException ex) {
if (ex.getLinkedException() instanceof IOException) {
// ActiveMQ is not running. Do some logic here.
// use the TransportListener to restart the activeMQ connection
// when activeMQ comes back up.
} else {
// Something seriously went wrong with the factory or connection
// creation. Abort the process here, as nothing can be done.
// Log the error and troubleshoot.
}
}
代码示例来源:origin: jiangmin168168/jim-framework
public PooledConnectionFactory create(String brokerClusterUrl){
ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory();
mqConnectionFactory.setBrokerURL(brokerClusterUrl);
mqConnectionFactory.setTransportListener(this);
//mqConnectionFactory.
PooledConnectionFactory connectionFactory = new JimPooledConnectionFactory(mqConnectionFactory);
connectionFactory.setMaxConnections(1);
connectionFactory.setCreateConnectionOnStartup(true);
return connectionFactory;
}
@Override
代码示例来源:origin: jiangmin168168/jim-framework
public PooledConnectionFactory create(String brokerClusterUrl){
ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory();
mqConnectionFactory.setBrokerURL(brokerClusterUrl);
mqConnectionFactory.setTransportListener(this);
//mqConnectionFactory.
PooledConnectionFactory connectionFactory = new JimPooledConnectionFactory(mqConnectionFactory);
connectionFactory.setMaxConnections(10);
connectionFactory.setTimeBetweenExpirationCheckMillis(1000);
//connectionFactory.setCreateConnectionOnStartup(true);
return connectionFactory;
}
内容来源于网络,如有侵权,请联系作者删除!