Search in sources :

Example 6 with ActiveMQPrefetchPolicy

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

the class NetworkLoadTest method createConnection.

protected Connection createConnection(int brokerId) throws JMSException {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:" + (60000 + brokerId));
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setUseCompression(false);
    connectionFactory.setDispatchAsync(true);
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setOptimizeAcknowledge(false);
    connectionFactory.setWatchTopicAdvisories(false);
    ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
    qPrefetchPolicy.setQueuePrefetch(100);
    qPrefetchPolicy.setTopicPrefetch(1000);
    connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
    connectionFactory.setAlwaysSyncSend(true);
    return connectionFactory.createConnection();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy)

Example 7 with ActiveMQPrefetchPolicy

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

the class ConcurrentProducerDurableConsumerTest 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 8 with ActiveMQPrefetchPolicy

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

the class NetworkBrokerDetachTest method createConnectionFactory.

protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
    String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setUseCompression(false);
    connectionFactory.setDispatchAsync(false);
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setOptimizeAcknowledge(false);
    connectionFactory.setWatchTopicAdvisories(true);
    ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
    qPrefetchPolicy.setQueuePrefetch(100);
    qPrefetchPolicy.setTopicPrefetch(1000);
    connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
    connectionFactory.setAlwaysSyncSend(true);
    return connectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy)

Example 9 with ActiveMQPrefetchPolicy

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

the class AbortSlowConsumer0Test method testAbortConsumerOnDeadConnection.

@Test
public void testAbortConsumerOnDeadConnection() throws Exception {
    TransportConnector transportConnector = broker.addConnector("tcp://0.0.0.0:0");
    transportConnector.setBrokerService(broker);
    transportConnector.setTaskRunnerFactory(broker.getTaskRunnerFactory());
    transportConnector.start();
    SocketProxy socketProxy = new SocketProxy(transportConnector.getPublishableConnectURI());
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(socketProxy.getUrl());
    ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
    prefetchPolicy.setAll(4);
    connectionFactory.setPrefetchPolicy(prefetchPolicy);
    Connection c = connectionFactory.createConnection();
    connections.add(c);
    c.start();
    Session session = c.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    final ActiveMQMessageConsumer messageconsumer = (ActiveMQMessageConsumer) session.createConsumer(destination);
    startProducers(destination, 10);
    messageconsumer.receive(4000).acknowledge();
    assertNotNull(messageconsumer.receive(4000));
    assertNotNull(messageconsumer.receive(4000));
    assertNotNull(messageconsumer.receive(4000));
    // close control command won't get through
    socketProxy.pause();
    ActiveMQDestination amqDest = (ActiveMQDestination) destination;
    ObjectName destinationViewMBean = new ObjectName("org.apache.activemq:destinationType=" + (amqDest.isTopic() ? "Topic" : "Queue") + ",destinationName=" + amqDest.getPhysicalName() + ",type=Broker,brokerName=localhost");
    final DestinationViewMBean destView = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(destinationViewMBean, DestinationViewMBean.class, true);
    assertTrue("Consumer gone from broker view", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            LOG.info("DestView {} consumerCount {}", destView, destView.getConsumerCount());
            return 0 == destView.getConsumerCount();
        }
    }));
    socketProxy.goOn();
    assertTrue("consumer was closed", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            boolean closed = false;
            try {
                messageconsumer.receive(400);
            } catch (javax.jms.IllegalStateException expected) {
                closed = expected.toString().contains("closed");
            }
            return closed;
        }
    }));
}
Also used : DestinationViewMBean(org.apache.activemq.broker.jmx.DestinationViewMBean) ActiveMQMessageConsumer(org.apache.activemq.ActiveMQMessageConsumer) Connection(javax.jms.Connection) SocketProxy(org.apache.activemq.util.SocketProxy) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) ObjectName(javax.management.ObjectName) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy) Session(javax.jms.Session) Test(org.junit.Test)

Example 10 with ActiveMQPrefetchPolicy

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

the class TopicDurableConnectStatsTest method createConnectionFactory.

@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    connectionFactory = new ActiveMQConnectionFactory("vm://" + getName(true));
    ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
    prefetchPolicy.setAll(10);
    connectionFactory.setPrefetchPolicy(prefetchPolicy);
    connectionFactory.setWatchTopicAdvisories(false);
    return connectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ActiveMQPrefetchPolicy(org.apache.activemq.ActiveMQPrefetchPolicy)

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