コード例 #1
0
  private static synchronized void initMQConnectionFactory() {

    pool_conn_factory = new PooledConnectionFactory();

    MQConfig config = new MQConfig();

    String url = config.getProperty(MQConfig.ACTIVEMQ_CONN_URL, DEFAULT_URL);

    String user = config.getProperty(MQConfig.ACTIVEMQ_CONN_USER, DEFAULT_USER);

    String passwd = config.getProperty(MQConfig.ACTIVEMQ_CONN_PASSWD, DEFAULT_PASSWORD);

    ActiveMQConnectionFactory activeMQConnFactory =
        new ActiveMQConnectionFactory(user, passwd, url);

    if (Boolean.TRUE
        .toString()
        .equalsIgnoreCase(config.getProperty(MQConfig.ACTIVEMQ_POOL_USE_ASYNCSEND, "false"))) {
      activeMQConnFactory.setUseAsyncSend(true);
    }

    pool_conn_factory.setConnectionFactory(activeMQConnFactory);

    pool_conn_factory.setMaxConnections(
        config.getIntProperty(MQConfig.ACTIVEMQ_POOL_CONN_MAX, "10"));

    // Sets the maximum number of active sessions per connection
    pool_conn_factory.setMaximumActive(
        config.getIntProperty(MQConfig.ACTIVEMQ_POOL_ACTIVE_SESSION_MAX, "200"));

    pool_conn_factory.setIdleTimeout(
        config.getIntProperty(MQConfig.ACTIVEMQ_POOL_IDLETIMEOUT, "30000"));
  }
コード例 #2
0
 public static ConnectionFactory createConnectionFactory(String options) {
   String url = "vm://test-broker?broker.persistent=false&broker.useJmx=false";
   if (options != null) {
     url = url + "&" + options;
   }
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
   // use a pooled connection factory
   PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
   pooled.setMaxConnections(8);
   return pooled;
 }