Java Code Examples for org.apache.activemq.ActiveMQConnectionFactory#setOptimizeAcknowledge()
The following examples show how to use
org.apache.activemq.ActiveMQConnectionFactory#setOptimizeAcknowledge() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkBrokerDetachTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: NetworkLoadTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: FailoverStaticNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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.setDispatchAsync(false); connectionFactory.setUseAsyncSend(false); connectionFactory.setOptimizeAcknowledge(false); connectionFactory.setAlwaysSyncSend(true); return connectionFactory; }
Example 4
Source File: GeneralInteropTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testFailoverReceivingFromCore() throws Exception { final int prefetchSize = 10; final String text = "HelloWorld"; sendMultipleTextMessagesUsingCoreJms(queueName, text, 100); //Initialize a failover connectionFactory. String urlString = "failover:(tcp://" + OWHOST + ":" + OWPORT + "?wireFormat.MaxInactivityDuration=5000)"; ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(urlString); connectionFactory.setSendAcksAsync(false); connectionFactory.setOptimizeAcknowledge(false); connectionFactory.getPrefetchPolicy().setAll(prefetchSize); Connection connection = connectionFactory.createConnection(); try { connection.setClientID("test.consumer.queue." + queueName); connection.start(); Message message = null; Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); QueueControl queueControl = (QueueControl)server.getManagementService(). getResource(ResourceNames.QUEUE + queueName); MessageConsumer consumer = session.createConsumer(queue); message = consumer.receive(5000); assertNotNull(message); assertTrue(message instanceof TextMessage); assertEquals(text + 0, ((TextMessage)message).getText()); message.acknowledge(); Wait.assertEquals(1L, () -> queueControl.getMessagesAcknowledged(), 3000, 100); Wait.assertEquals(prefetchSize, () -> queueControl.getDeliveringCount(), 3000, 100); //Force a disconnection. for (ServerSession serverSession : server.getSessions()) { if (session.toString().contains(serverSession.getName())) { serverSession.getRemotingConnection().fail(new ActiveMQDisconnectedException()); } } Wait.assertEquals(1L, () -> queueControl.getMessagesAcknowledged(), 3000, 100); Wait.assertEquals(prefetchSize, () -> queueControl.getDeliveringCount(), 3000, 100); message = consumer.receive(5000); assertNotNull(message); assertTrue(message instanceof TextMessage); assertEquals(text + 1, ((TextMessage)message).getText()); message.acknowledge(); Wait.assertEquals(2L, () -> queueControl.getMessagesAcknowledged(), 3000, 100); Wait.assertEquals(prefetchSize, () -> queueControl.getDeliveringCount(), 30000, 100); } finally { connection.close(); } }
Example 5
Source File: FailoverDuplicateTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void configureConnectionFactory(ActiveMQConnectionFactory factory) { factory.setAuditMaximumProducerNumber(2048); factory.setOptimizeAcknowledge(true); }
Example 6
Source File: MemoryLimitTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test(timeout = 120000) public void testCursorBatch() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?jms.prefetchPolicy.all=10"); factory.setOptimizeAcknowledge(true); Connection conn = factory.createConnection(); conn.start(); Session sess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE); Queue queue = sess.createQueue("STORE"); final ProducerThread producer = new ProducerThread(sess, queue) { @Override protected Message createMessage(int i) throws Exception { BytesMessage bytesMessage = sess.createBytesMessage(); bytesMessage.writeBytes(payload); return bytesMessage; } }; producer.setMessageCount(2000); producer.start(); producer.join(); Thread.sleep(1000); // assert we didn't break high watermark (70%) usage final Destination dest = broker.getDestination((ActiveMQQueue) queue); LOG.info("Destination usage: " + dest.getMemoryUsage()); int percentUsage = dest.getMemoryUsage().getPercentUsage(); assertTrue("Should be less than 70% of limit but was: " + percentUsage, percentUsage <= 71); LOG.info("Broker usage: " + broker.getSystemUsage().getMemoryUsage()); assertTrue(broker.getSystemUsage().getMemoryUsage().getPercentUsage() <= 71); // consume one message MessageConsumer consumer = sess.createConsumer(queue); Message msg = consumer.receive(5000); msg.acknowledge(); // this should free some space and allow us to get new batch of messages in the memory // exceeding the limit assertTrue("Limit is exceeded", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { LOG.info("Destination usage: " + dest.getMemoryUsage()); return dest.getMemoryUsage().getPercentUsage() >= 200; } })); LOG.info("Broker usage: " + broker.getSystemUsage().getMemoryUsage()); assertTrue(broker.getSystemUsage().getMemoryUsage().getPercentUsage() >= 200); // let's make sure we can consume all messages for (int i = 1; i < 2000; i++) { msg = consumer.receive(5000); if (msg == null) { dumpAllThreads("NoMessage"); } assertNotNull("Didn't receive message " + i, msg); msg.acknowledge(); } }