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();
}
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;
}
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;
}
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;
}
}));
}
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;
}
Aggregations