本文整理汇总了Java中org.apache.activemq.pool.PooledConnectionFactory.setMaximumActiveSessionPerConnection方法的典型用法代码示例。如果您正苦于以下问题:Java PooledConnectionFactory.setMaximumActiveSessionPerConnection方法的具体用法?Java PooledConnectionFactory.setMaximumActiveSessionPerConnection怎么用?Java PooledConnectionFactory.setMaximumActiveSessionPerConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.pool.PooledConnectionFactory
的用法示例。
在下文中一共展示了PooledConnectionFactory.setMaximumActiveSessionPerConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newAMQInstance
import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
public static ActiveMQComponent newAMQInstance(){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm:localhost");
// use a pooled connection factory between the module and the queue
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);
// how many connections should there be in the session pool?
pooledConnectionFactory.setMaxConnections(100);
pooledConnectionFactory.setMaximumActiveSessionPerConnection(100);
pooledConnectionFactory.setCreateConnectionOnStartup(true);
pooledConnectionFactory.setBlockIfSessionPoolIsFull(false);
JmsConfiguration jmsConfiguration = new JmsConfiguration(pooledConnectionFactory);
jmsConfiguration.setDeliveryPersistent(false);
jmsConfiguration.setTimeToLive(1000*10);
ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("vm:localhost");
return activeMQComponent;
}
示例2: addMQPool
import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
public void addMQPool(String url, String username, String password) {
connectionPool = new PooledConnectionFactory(url);
connectionPool.setMaxConnections(maxTotal);
connectionPool.setMaximumActiveSessionPerConnection(maxIdle);
connectionPool.setIdleTimeout(maxWaitMillis);
this.username = username;
this.password = password;
}
示例3: 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();
}