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


Java PooledConnectionFactory.start方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:yuruki,项目名称:camel-runner,代码行数:12,代码来源:PooledAmqComponent.java

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

示例3: AMQConnectionResource

import org.apache.activemq.pool.PooledConnectionFactory; //导入方法依赖的package包/类
public AMQConnectionResource(String connectString, int maxConnections) {
    pcf = new PooledConnectionFactory(connectString);
    pcf.setMaxConnections(maxConnections);
    pcf.start();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:ConnectionResourceIT.java


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