当前位置: 首页>>代码示例>>Java>>正文


Java PooledConnectionFactory.setMaximumActiveSessionPerConnection方法代码示例

本文整理汇总了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;
}
 
开发者ID:SignalK,项目名称:signalk-server-java,代码行数:19,代码来源:ActiveMqBrokerFactory.java

示例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;
}
 
开发者ID:yiyongfei,项目名称:jea,代码行数:9,代码来源:ActiveMQPool.java

示例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();
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:43,代码来源:EdsTest.java


注:本文中的org.apache.activemq.pool.PooledConnectionFactory.setMaximumActiveSessionPerConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。