Java Code Examples for org.apache.activemq.artemis.core.settings.impl.AddressSettings#setAddressFullMessagePolicy()
The following examples show how to use
org.apache.activemq.artemis.core.settings.impl.AddressSettings#setAddressFullMessagePolicy() .
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: JMSMessageGroupsTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected void configureAddressPolicy(ActiveMQServer server) { super.configureAddressPolicy(server); AddressSettings addressSettings = new AddressSettings(); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setAutoCreateQueues(isAutoCreateQueues()); addressSettings.setAutoCreateAddresses(isAutoCreateAddresses()); addressSettings.setDeadLetterAddress(SimpleString.toSimpleString(getDeadLetterAddress())); addressSettings.setExpiryAddress(SimpleString.toSimpleString(getDeadLetterAddress())); addressSettings.setDefaultGroupFirstKey(SimpleString.toSimpleString("JMSXFirstInGroupID")); server.getConfiguration().getAddressesSettings().put("GroupFirst.#", addressSettings); }
Example 2
Source File: AmqpClientTestSupport.java From activemq-artemis with Apache License 2.0 | 6 votes |
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(getDeadLetterAddress())); server.getConfiguration().getAddressesSettings().put("#", addressSettings); Set<TransportConfiguration> acceptors = server.getConfiguration().getAcceptorConfigurations(); for (TransportConfiguration tc : acceptors) { if (tc.getName().equals("netty-acceptor")) { tc.getExtraParams().put("anycastPrefix", "anycast://"); tc.getExtraParams().put("multicastPrefix", "multicast://"); } } }
Example 3
Source File: ArtemisBrokerBase.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected final ActiveMQServer createServer(final boolean realFiles, final Configuration configuration, final int pageSize, final int maxAddressSize, final AddressFullMessagePolicy fullPolicy, final Map<String, AddressSettings> settings) { ActiveMQServer server = ActiveMQServers.newActiveMQServer(configuration, realFiles); if (settings != null) { for (Map.Entry<String, AddressSettings> setting : settings.entrySet()) { server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue()); } } AddressSettings defaultSetting = new AddressSettings(); defaultSetting.setPageSizeBytes(pageSize); defaultSetting.setMaxSizeBytes(maxAddressSize); defaultSetting.setAddressFullMessagePolicy(fullPolicy); server.getAddressSettingsRepository().addMatch("#", defaultSetting); return server; }
Example 4
Source File: SlowConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Before @Override public void setUp() throws Exception { super.setUp(); server = createServer(true, isNetty); AddressSettings addressSettings = new AddressSettings(); addressSettings.setSlowConsumerCheckPeriod(checkPeriod); addressSettings.setSlowConsumerThreshold(threshold); addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.KILL); if (isPaging) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setMaxSizeBytes(10 * 1024); addressSettings.setPageSizeBytes(1024); } else { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); addressSettings.setMaxSizeBytes(-1); addressSettings.setPageSizeBytes(1024); } server.start(); server.getAddressSettingsRepository().addMatch(QUEUE.toString(), addressSettings); server.createQueue(new QueueConfiguration(QUEUE).setRoutingType(RoutingType.ANYCAST)).getPageSubscription().getPagingStore().startPaging(); locator = createFactory(isNetty); }
Example 5
Source File: ClusteredMessageCounterTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected ConfigurationImpl createBasicConfig(final int serverID) { ConfigurationImpl config = super.createBasicConfig(serverID); Map<String, AddressSettings> addrSettingsMap = config.getAddressesSettings(); AddressSettings addrSettings = new AddressSettings(); addrSettings.setMaxSizeBytes(10 * 1024); addrSettings.setPageSizeBytes(5 * 1024); addrSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addrSettingsMap.put("queues", addrSettings); if (serverID == 1) { config.setMessageCounterEnabled(true); } return config; }
Example 6
Source File: AmqpFlowControlTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureAddressPolicy(ActiveMQServer server) { // For BLOCK tests AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch("#"); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); addressSettings.setMaxSizeBytes(MAX_SIZE_BYTES); addressSettings.setMaxSizeBytesRejectThreshold(MAX_SIZE_BYTES_REJECT_THRESHOLD); server.getAddressSettingsRepository().addMatch("#", addressSettings); }
Example 7
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 8
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 9
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 10
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 11
Source File: Async.java From javalite with Apache License 2.0 | 5 votes |
private void configurePaging() { AddressSettings addressSettings = new AddressSettings(); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setMaxSizeBytes(30 * 1024 * 1024L); addressSettings.setPageSizeBytes(10 * 1024 * 1024); addressSettings.setPageCacheMaxSize(20); config.getAddressesSettings().put("jms.queue.*", addressSettings); }
Example 12
Source File: SlowConsumerTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testSlowConsumerNotification() throws Exception { ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = addClientSession(sf.createSession(false, true, true, false)); AddressSettings addressSettings = new AddressSettings(); addressSettings.setSlowConsumerCheckPeriod(2); addressSettings.setSlowConsumerThreshold(10); addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY); if (!isPaging) { addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); addressSettings.setMaxSizeBytes(-1); } server.getAddressSettingsRepository().removeMatch(QUEUE.toString()); server.getAddressSettingsRepository().addMatch(QUEUE.toString(), addressSettings); assertPaging(); ClientProducer producer = addClientProducer(session.createProducer(QUEUE)); final int numMessages = 25; for (int i = 0; i < numMessages; i++) { producer.send(createTextMessage(session, "m" + i)); } SimpleString notifQueue = RandomUtil.randomSimpleString(); session.createQueue(new QueueConfiguration(notifQueue).setAddress(ActiveMQDefaultConfiguration.getDefaultManagementNotificationAddress()).setDurable(false)); ClientConsumer notifConsumer = session.createConsumer(notifQueue.toString(), ManagementHelper.HDR_NOTIFICATION_TYPE + "='" + CoreNotificationType.CONSUMER_SLOW + "'"); final CountDownLatch notifLatch = new CountDownLatch(1); notifConsumer.setMessageHandler(new MessageHandler() { @Override public void onMessage(ClientMessage message) { assertEquals(CoreNotificationType.CONSUMER_SLOW.toString(), message.getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString()); assertEquals(QUEUE.toString(), message.getObjectProperty(ManagementHelper.HDR_ADDRESS).toString()); assertEquals(Integer.valueOf(1), message.getIntProperty(ManagementHelper.HDR_CONSUMER_COUNT)); if (isNetty) { assertTrue(message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString().startsWith("/127.0.0.1")); } else { assertEquals(SimpleString.toSimpleString("invm:0"), message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); } assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME)); assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_CONSUMER_NAME)); assertNotNull(message.getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME)); try { message.acknowledge(); } catch (ActiveMQException e) { e.printStackTrace(); } notifLatch.countDown(); } }); ClientConsumer consumer = addClientConsumer(session.createConsumer(QUEUE)); session.start(); assertTrue(notifLatch.await(15, TimeUnit.SECONDS)); }
Example 13
Source File: AmqpFlowControlFailTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
private static void configureAddressPolicy(final ActiveMQServer server) { AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch("#"); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL); addressSettings.setMaxSizeBytes(1000); server.getAddressSettingsRepository().addMatch("#", addressSettings); }
Example 14
Source File: FileMoveManagerTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test public void testMoveOverPaging() throws Exception { AssertionLoggerHandler.startCapture(); ExecutorService threadPool = Executors.newCachedThreadPool(); try { manager.setMaxFolders(3); for (int i = 1; i <= 10; i++) { HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<>(); AddressSettings settings = new AddressSettings(); settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setDefault(settings); final StorageManager storageManager = new NullStorageManager(); PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, dataLocation, 100, null, new OrderedExecutorFactory(threadPool), true, null); PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings, -1, ActiveMQDefaultConfiguration.getDefaultManagementAddress()); managerImpl.start(); PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test")); store.startPaging(); store.stop(); managerImpl.stop(); manager.doMove(); Assert.assertEquals(Math.min(i, manager.getMaxFolders()), manager.getNumberOfFolders()); } Assert.assertFalse("The loggers are complaining about address.txt", AssertionLoggerHandler.findText("address.txt")); } finally { AssertionLoggerHandler.stopCapture(); threadPool.shutdown(); } }