Package org.apache.activemq.pool

Examples of org.apache.activemq.pool.PooledConnectionFactory


    public synchronized CamelContext getCamelContext() {
      if (camelContext == null) {
        LOG.debug("Creating camel context");
        camelContext = new DefaultCamelContext();
        ActiveMQConfiguration conf = new ActiveMQConfiguration();
        conf.setConnectionFactory(new PooledConnectionFactory((ActiveMQConnectionFactory)factory));
        ActiveMQComponent component = new ActiveMQComponent(conf);
        camelContext.addComponent("activemq", component);
      }
      return camelContext;
    }
View Full Code Here


  // This should fail with incubator-activemq-fuse-4.1.0.5
  public void testQueueLimitsWithOneBrokerSameConnection() throws Exception {

    BrokerService brokerService1 = null;
    ActiveMQConnectionFactory acf = null;
    PooledConnectionFactory pcf = null;
    DefaultMessageListenerContainer container1 = null;

    try {
      brokerService1 = createBrokerService("broker1", URL1, null);
      brokerService1.start();

      acf = createConnectionFactory(URL1);
      pcf = new PooledConnectionFactory(acf);

      // Only listen on the first queue.. let the 2nd queue fill up.
      doneLatch = new CountDownLatch(NUM_MESSAGE_TO_SEND);
      container1 = createDefaultMessageListenerContainer(acf,  new TestMessageListener1(500), QUEUE1_NAME);
      container1.afterPropertiesSet();
View Full Code Here

    BrokerService brokerService1 = null;
    BrokerService brokerService2 = null;
    ActiveMQConnectionFactory acf1 = null;
    ActiveMQConnectionFactory acf2 = null;
    PooledConnectionFactory pcf = null;
    DefaultMessageListenerContainer container1 = null;

    try {
      brokerService1 = createBrokerService("broker1", URL1, URL2);
      brokerService1.start();
      brokerService2 = createBrokerService("broker2", URL2, URL1);
      brokerService2.start();

      acf1 = createConnectionFactory(URL1);
      acf2 = createConnectionFactory(URL2);

      pcf = new PooledConnectionFactory(acf1);

      Thread.sleep(1000);

      doneLatch = new CountDownLatch(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND);
      container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(500), QUEUE1_NAME);
View Full Code Here

        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;
    }
View Full Code Here

    private CamelContext createSenderContext() throws Exception {

        ActiveMQConnectionFactory amqFactory = new ActiveMQConnectionFactory(connectionUri);
        amqFactory.setWatchTopicAdvisories(false);

        PooledConnectionFactory pooled = new PooledConnectionFactory(amqFactory);
        pooled.setMaxConnections(1);
        pooled.setMaximumActiveSessionPerConnection(500);
        // If this is not zero the connection could get closed and the request
        // reply can fail.
        pooled.setIdleTimeout(0);

        CamelContext camelContext = new DefaultCamelContext();
        ActiveMQComponent amqComponent = new ActiveMQComponent();
        amqComponent.setConnectionFactory(pooled);
        camelContext.addComponent("activemq", amqComponent);
View Full Code Here

    ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
    prefetch.setQueuePrefetch(1);
    ActiveMQConnectionFactory  amq = new ActiveMQConnectionFactory(url);
    amq.setPrefetchPolicy(prefetch);
   
    connectionFactory = new PooledConnectionFactory(amq);
    ((PooledConnectionFactory)connectionFactory).setMaxConnections(5);


    StringBuffer buffer = new StringBuffer();   
    for (int i=0; i<2048; i++) {
View Full Code Here

        connectionFactory.setOptimizeAcknowledge(true);
        connectionFactory.setOptimizedMessageDispatch(true);
        connectionFactory.setUseAsyncSend(true);
        connectionFactory.setAlwaysSessionAsync(false);
        // use a pooled connection factory
        PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
        pooled.setMaxConnections(8);
        return pooled;
    }
View Full Code Here

        connectionFactory.setOptimizedMessageDispatch(true);
        connectionFactory.setUseAsyncSend(true);
        connectionFactory.setAlwaysSessionAsync(false);

        // use a pooled connection factory
        PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
        pooled.setMaxConnections(8);
        return pooled;
    }
View Full Code Here

        BrokerService brokerService2 = null;
        BrokerService brokerService3 = null;
        BrokerService brokerService4 = null;
        ActiveMQConnectionFactory acf1 = null;
        ActiveMQConnectionFactory acf2 = null;
        PooledConnectionFactory pcf1 = null;
        PooledConnectionFactory pcf2 = null;
        ActiveMQConnectionFactory acf3 = null;
        ActiveMQConnectionFactory acf4 = null;
        PooledConnectionFactory pcf3 = null;
        PooledConnectionFactory pcf4 = null;
        DefaultMessageListenerContainer container1 = null;

        try {

            // Test with and without queue limits.
            brokerService1 = createBrokerService("broker1", BROKER_URL1, BROKER_URL2, BROKER_URL3, BROKER_URL4, 0 /* 10000000 */);
            brokerService1.start();
            brokerService2 = createBrokerService("broker2", BROKER_URL2, BROKER_URL1, BROKER_URL3, BROKER_URL4, 0/* 40000000 */);
            brokerService2.start();
            brokerService3 = createBrokerService("broker3", BROKER_URL3, BROKER_URL2, BROKER_URL1, BROKER_URL4, 0/* 10000000 */);
            brokerService3.start();
            brokerService4 = createBrokerService("broker4", BROKER_URL4, BROKER_URL1, BROKER_URL3, BROKER_URL2, 0/* 10000000 */);
            brokerService4.start();

            final String failover1 = "failover:(" + URL1
                                     + ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";
            final String failover2 = "failover:(" + URL2
                                     + ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";

            final String failover3 = "failover:(" + URL3
                                     + ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";

            final String failover4 = "failover:(" + URL4
                                     + ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";

            acf1 = createConnectionFactory(failover1);
            acf2 = createConnectionFactory(failover2);
            acf3 = createConnectionFactory(failover3);
            acf4 = createConnectionFactory(failover4);

            pcf1 = new PooledConnectionFactory(acf1);
            pcf2 = new PooledConnectionFactory(acf2);
            pcf3 = new PooledConnectionFactory(acf3);
            pcf4 = new PooledConnectionFactory(acf4);

            container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(0), QUEUE1_NAME);
            container1.afterPropertiesSet();

            final PooledProducerTask[] task = new PooledProducerTask[4];
View Full Code Here

            public Object call() throws Exception {
                try {
                    final int batch = 10;
                    ActiveMQConnectionFactory connectionFactory2 =
                        new ActiveMQConnectionFactory("failover:(tcp://localhost:51515)");
                    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(connectionFactory2);
                    connectionFactory2.setWatchTopicAdvisories(false);
                    JmsTemplate template = new JmsTemplate(pooledConnectionFactory);
                    ActiveMQQueue queue = new ActiveMQQueue("testingqueue");
                    for(int b = 0; b < batch; b++) {
                        for(int i = 0; i < (total / batch); i++) {
View Full Code Here

TOP

Related Classes of org.apache.activemq.pool.PooledConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.