Java Code Examples for org.apache.activemq.artemis.core.settings.impl.AddressSettings#setMaxDeliveryAttempts()
The following examples show how to use
org.apache.activemq.artemis.core.settings.impl.AddressSettings#setMaxDeliveryAttempts() .
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: DLQAfterExpiredMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureAddressPolicy(ActiveMQServer server) { // Address configuration AddressSettings addressSettings = new AddressSettings(); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setAutoCreateQueues(isAutoCreateQueues()); addressSettings.setAutoCreateAddresses(isAutoCreateAddresses()); addressSettings.setDeadLetterAddress(SimpleString.toSimpleString(getDeadLetterAddress())); addressSettings.setExpiryAddress(SimpleString.toSimpleString(getExpiryQueue())); addressSettings.setMaxDeliveryAttempts(1); server.getConfiguration().getAddressesSettings().put("#", addressSettings); server.getConfiguration().getAddressesSettings().put(getExpiryQueue(), addressSettings); }
Example 2
Source File: AddressSettingsTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSingleMerge() { AddressSettings addressSettings = new AddressSettings(); AddressSettings addressSettingsToMerge = new AddressSettings(); SimpleString DLQ = new SimpleString("testDLQ"); SimpleString exp = new SimpleString("testExpiryQueue"); addressSettingsToMerge.setDeadLetterAddress(DLQ); addressSettingsToMerge.setExpiryAddress(exp); addressSettingsToMerge.setMaxDeliveryAttempts(1000); addressSettingsToMerge.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP); addressSettingsToMerge.setMaxSizeBytes(1001); addressSettingsToMerge.setMessageCounterHistoryDayLimit(1002); addressSettingsToMerge.setRedeliveryDelay(1003); addressSettingsToMerge.setPageSizeBytes(1004); addressSettingsToMerge.setMaxSizeBytesRejectThreshold(10 * 1024); addressSettings.merge(addressSettingsToMerge); Assert.assertEquals(addressSettings.getDeadLetterAddress(), DLQ); Assert.assertEquals(addressSettings.getExpiryAddress(), exp); Assert.assertEquals(addressSettings.getMaxDeliveryAttempts(), 1000); Assert.assertEquals(addressSettings.getMaxSizeBytes(), 1001); Assert.assertEquals(addressSettings.getMessageCounterHistoryDayLimit(), 1002); Assert.assertEquals(addressSettings.getRedeliveryDelay(), 1003); Assert.assertEquals(addressSettings.getPageSizeBytes(), 1004); Assert.assertEquals(AddressFullMessagePolicy.DROP, addressSettings.getAddressFullMessagePolicy()); Assert.assertEquals(addressSettings.getMaxSizeBytesRejectThreshold(), 10 * 1024); }
Example 3
Source File: AddressSettingsTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testMultipleMerge() { AddressSettings addressSettings = new AddressSettings(); AddressSettings addressSettingsToMerge = new AddressSettings(); SimpleString DLQ = new SimpleString("testDLQ"); SimpleString exp = new SimpleString("testExpiryQueue"); addressSettingsToMerge.setDeadLetterAddress(DLQ); addressSettingsToMerge.setExpiryAddress(exp); addressSettingsToMerge.setMaxDeliveryAttempts(1000); addressSettingsToMerge.setMaxSizeBytes(1001); addressSettingsToMerge.setMessageCounterHistoryDayLimit(1002); addressSettingsToMerge.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP); addressSettingsToMerge.setMaxSizeBytesRejectThreshold(10 * 1024); addressSettings.merge(addressSettingsToMerge); AddressSettings addressSettingsToMerge2 = new AddressSettings(); SimpleString exp2 = new SimpleString("testExpiryQueue2"); addressSettingsToMerge2.setExpiryAddress(exp2); addressSettingsToMerge2.setMaxSizeBytes(2001); addressSettingsToMerge2.setRedeliveryDelay(2003); addressSettingsToMerge2.setRedeliveryMultiplier(2.5); addressSettings.merge(addressSettingsToMerge2); Assert.assertEquals(addressSettings.getDeadLetterAddress(), DLQ); Assert.assertEquals(addressSettings.getExpiryAddress(), exp); Assert.assertEquals(addressSettings.getMaxDeliveryAttempts(), 1000); Assert.assertEquals(addressSettings.getMaxSizeBytes(), 1001); Assert.assertEquals(addressSettings.getMessageCounterHistoryDayLimit(), 1002); Assert.assertEquals(addressSettings.getRedeliveryDelay(), 2003); Assert.assertEquals(addressSettings.getRedeliveryMultiplier(), 2.5, 0.000001); Assert.assertEquals(AddressFullMessagePolicy.DROP, addressSettings.getAddressFullMessagePolicy()); Assert.assertEquals(addressSettings.getMaxSizeBytesRejectThreshold(), 10 * 1024); }
Example 4
Source File: AddressSettingsTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testMultipleMergeAll() { AddressSettings addressSettings = new AddressSettings(); AddressSettings addressSettingsToMerge = new AddressSettings(); SimpleString DLQ = new SimpleString("testDLQ"); SimpleString exp = new SimpleString("testExpiryQueue"); addressSettingsToMerge.setDeadLetterAddress(DLQ); addressSettingsToMerge.setExpiryAddress(exp); addressSettingsToMerge.setMaxSizeBytes(1001); addressSettingsToMerge.setRedeliveryDelay(1003); addressSettingsToMerge.setRedeliveryMultiplier(1.0); addressSettingsToMerge.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP); addressSettings.merge(addressSettingsToMerge); AddressSettings addressSettingsToMerge2 = new AddressSettings(); SimpleString exp2 = new SimpleString("testExpiryQueue2"); SimpleString DLQ2 = new SimpleString("testDlq2"); addressSettingsToMerge2.setExpiryAddress(exp2); addressSettingsToMerge2.setDeadLetterAddress(DLQ2); addressSettingsToMerge2.setMaxDeliveryAttempts(2000); addressSettingsToMerge2.setMaxSizeBytes(2001); addressSettingsToMerge2.setMessageCounterHistoryDayLimit(2002); addressSettingsToMerge2.setRedeliveryDelay(2003); addressSettingsToMerge2.setRedeliveryMultiplier(2.0); addressSettingsToMerge2.setMaxRedeliveryDelay(5000); addressSettingsToMerge.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.merge(addressSettingsToMerge2); Assert.assertEquals(addressSettings.getDeadLetterAddress(), DLQ); Assert.assertEquals(addressSettings.getExpiryAddress(), exp); Assert.assertEquals(addressSettings.getMaxDeliveryAttempts(), 2000); Assert.assertEquals(addressSettings.getMaxSizeBytes(), 1001); Assert.assertEquals(addressSettings.getMessageCounterHistoryDayLimit(), 2002); Assert.assertEquals(addressSettings.getRedeliveryDelay(), 1003); Assert.assertEquals(addressSettings.getRedeliveryMultiplier(), 1.0, 0.000001); Assert.assertEquals(addressSettings.getMaxRedeliveryDelay(), 5000); Assert.assertEquals(AddressFullMessagePolicy.DROP, addressSettings.getAddressFullMessagePolicy()); }
Example 5
Source File: LargeMessageTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
private void internalTestRollbackPartiallyConsumedBuffer(final boolean redeliveryDelay) throws Exception { final int messageSize = largeMessageSize; final ClientSession session; ActiveMQServer server = createServer(true, isNetty(), storeType); AddressSettings settings = new AddressSettings(); if (redeliveryDelay) { settings.setRedeliveryDelay(100); if (locator.isCompressLargeMessage()) { locator.setConsumerWindowSize(0); } } locator.setBlockOnNonDurableSend(false).setBlockOnNonDurableSend(false).setBlockOnAcknowledge(false); settings.setMaxDeliveryAttempts(-1); server.getAddressSettingsRepository().addMatch("#", settings); server.start(); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); session = sf.createSession(false, false, false); session.createQueue(new QueueConfiguration(ADDRESS)); ClientProducer producer = session.createProducer(ADDRESS); for (int i = 0; i < 20; i++) { Message clientFile = createLargeClientMessageStreaming(session, messageSize, true); clientFile.putIntProperty("value", i); producer.send(clientFile); } session.commit(); session.start(); final CountDownLatch latch = new CountDownLatch(1); final AtomicInteger errors = new AtomicInteger(0); ClientConsumer consumer = session.createConsumer(ADDRESS); consumer.setMessageHandler(new MessageHandler() { int counter = 0; @Override public void onMessage(ClientMessage message) { message.getBodyBuffer().readByte(); // System.out.println("message:" + message); try { if (counter++ < 20) { // System.out.println("Rollback"); message.acknowledge(); session.rollback(); } else { message.acknowledge(); session.commit(); } if (counter == 40) { latch.countDown(); } } catch (Exception e) { latch.countDown(); e.printStackTrace(); errors.incrementAndGet(); } } }); assertTrue(latch.await(40, TimeUnit.SECONDS)); consumer.close(); session.close(); validateNoFilesOnLargeDir(); }