Search in sources :

Example 11 with ActiveMQPrefetchPolicy

use of org.apache.activemq.ActiveMQPrefetchPolicy in project activemq-artemis by apache.

the class ConcurrentProducerQueueConsumerTest method createConnectionFactory.

@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
    ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
    prefetchPolicy.setAll(1);
    factory.setPrefetchPolicy(prefetchPolicy);
    factory.setDispatchAsync(true);
    return factory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy)

Example 12 with ActiveMQPrefetchPolicy

use of org.apache.activemq.ActiveMQPrefetchPolicy in project activemq-artemis by apache.

the class SimpleNetworkTest method setUp.

@Override
protected void setUp() throws Exception {
    if (consumerBroker == null) {
        consumerBroker = createConsumerBroker(consumerBindAddress);
    }
    if (producerBroker == null) {
        producerBroker = createProducerBroker(producerBindAddress);
    }
    consumerFactory = createConnectionFactory(consumerBindAddress);
    consumerFactory.setDispatchAsync(true);
    ActiveMQPrefetchPolicy policy = new ActiveMQPrefetchPolicy();
    policy.setQueuePrefetch(100);
    consumerFactory.setPrefetchPolicy(policy);
    producerFactory = createConnectionFactory(producerBindAddress);
    Connection con = consumerFactory.createConnection();
    Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
    producers = new PerfProducer[numberofProducers * numberOfDestinations];
    consumers = new PerfConsumer[numberOfConsumers * numberOfDestinations];
    for (int k = 0; k < numberOfDestinations; k++) {
        Destination destination = createDestination(session, destinationName + ":" + k);
        LOG.info("Testing against destination: " + destination);
        for (int i = 0; i < numberOfConsumers; i++) {
            consumers[i] = createConsumer(consumerFactory, destination, i);
            consumers[i].start();
        }
        for (int i = 0; i < numberofProducers; i++) {
            array = new byte[playloadSize];
            for (int j = i; j < array.length; j++) {
                array[j] = (byte) j;
            }
            producers[i] = createProducer(producerFactory, destination, i, array);
            producers[i].start();
        }
    }
    con.close();
}
Also used : Destination(javax.jms.Destination) Connection(javax.jms.Connection) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy) Session(javax.jms.Session)

Aggregations

ActiveMQPrefetchPolicy (org.apache.activemq.ActiveMQPrefetchPolicy)12 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)9 Session (javax.jms.Session)4 Connection (javax.jms.Connection)3 Destination (javax.jms.Destination)2 Message (javax.jms.Message)2 MessageProducer (javax.jms.MessageProducer)2 URI (java.net.URI)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BytesMessage (javax.jms.BytesMessage)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageListener (javax.jms.MessageListener)1 Topic (javax.jms.Topic)1 ObjectName (javax.management.ObjectName)1 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)1 TransportConnector (org.apache.activemq.broker.TransportConnector)1 DestinationViewMBean (org.apache.activemq.broker.jmx.DestinationViewMBean)1 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)1 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)1 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)1