本文整理汇总了Java中org.apache.activemq.pool.PooledConnectionFactory.start方法的典型用法代码示例。如果您正苦于以下问题:Java PooledConnectionFactory.start方法的具体用法?Java PooledConnectionFactory.start怎么用?Java PooledConnectionFactory.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.pool.PooledConnectionFactory
的用法示例。
在下文中一共展示了PooledConnectionFactory.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPooledConnectionFactory
import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
private PooledConnectionFactory getPooledConnectionFactory(String brokerUrl) {
if (null != pooledConnectionFactory) {
return pooledConnectionFactory;
} else {
PooledConnectionFactory connectionFactory = new PooledConnectionFactory(brokerUrl);
connectionFactory.setMaxConnections(8);
connectionFactory.start();
this.pooledConnectionFactory = connectionFactory;
return pooledConnectionFactory;
}
}
示例2: startConsumer
import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
private void startConsumer(){
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
pooledConnectionFactory = new PooledConnectionFactory(factory);
pooledConnectionFactory.setReconnectOnException(true);
pooledConnectionFactory.setMaximumActiveSessionPerConnection(10); // 10
pooledConnectionFactory.setMaxConnections(10); // 10
pooledConnectionFactory.setIdleTimeout(300000); // 管理连接池中的连接,5分钟超时 300000
pooledConnectionFactory.setUseAnonymousProducers(false);
pooledConnectionFactory.start();
Thread t = new Thread(){
@Override
public void run() {
// consumer
Connection conn ;
Session sess;
MessageConsumer consumer;
try {
while(!shutdown){
conn = pooledConnectionFactory.createConnection();
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = sess.createQueue("_eds_"+queueName);
consumer = sess.createConsumer(dest);
Message msg = consumer.receive();
if(msg != null){
System.out.println("received => "+msg);
msgReceived.incrementAndGet();
}
consumer.close();
sess.close();
conn.close();
System.out.println("receiving => "+msg);
}
} catch (JMSException e) {
e.printStackTrace();
}
}
};
t.start();
}
示例3: AMQConnectionResource
import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
public AMQConnectionResource(String connectString, int maxConnections) {
pcf = new PooledConnectionFactory(connectString);
pcf.setMaxConnections(maxConnections);
pcf.start();
}