org.apache.activemq.broker.region.policy.PolicyMap Java Examples

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyMap. 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: AbortSlowConsumerBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();
   underTest.setAbortConnection(abortConnection);
   underTest.setCheckPeriod(checkPeriod);
   underTest.setMaxSlowDuration(maxSlowDuration);

   policy.setSlowConsumerStrategy(underTest);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example #2
Source File: JdbcDurableSubDupTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   exceptions.clear();
   for (int i = 0; i < MAX_MESSAGES; i++) {
      dupChecker[i] = 0;
   }
   broker = new BrokerService();
   broker.setAdvisorySupport(false);
   broker.setPersistenceAdapter(new JDBCPersistenceAdapter());
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setMaxAuditDepth(3000);
   policyEntry.setMaxPageSize(150);
   policyEntry.setPrioritizedMessages(true);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(policyEntry);
   broker.setDestinationPolicy(policyMap);

   broker.addConnector("tcp://localhost:0");
   broker.setDeleteAllMessagesOnStartup(true);
   broker.start();
   broker.waitUntilStarted();
   url = broker.getTransportConnectors().get(0).getConnectUri().toString() + "?" + urlOptions;
}
 
Example #3
Source File: AdvisoryTopicCleanUpTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void createBroker() throws Exception {
   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setUseJmx(true);
   connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();

   PolicyEntry policy = new PolicyEntry();
   policy.setAdvisoryForFastProducers(true);
   policy.setAdvisoryForConsumed(true);
   policy.setAdvisoryForDelivery(true);
   policy.setAdvisoryForDiscardingMessages(true);
   policy.setAdvisoryForSlowConsumers(true);
   policy.setAdvisoryWhenFull(true);
   policy.setProducerFlowControl(false);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);

   broker.start();
}
 
Example #4
Source File: AbortSlowAckConsumer1Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   AbortSlowAckConsumerStrategy strategy = new AbortSlowAckConsumerStrategy();
   strategy.setAbortConnection(abortConnection);
   strategy.setCheckPeriod(checkPeriod);
   strategy.setMaxSlowDuration(maxSlowDuration);
   strategy.setMaxTimeSinceLastAck(maxTimeSinceLastAck);

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example #5
Source File: DurableSubscriptionSelectorTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void startBroker(boolean deleteMessages) throws Exception {
   broker = new BrokerService();
   broker.setBrokerName("test-broker");

   if (deleteMessages) {
      broker.setDeleteAllMessagesOnStartup(true);
   }
   setDefaultPersistenceAdapter(broker);

     /* use maxPageSize policy in place of always pulling from the broker in maxRows chunks
     if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) {
         ((JDBCPersistenceAdapter)broker.getPersistenceAdapter()).setMaxRows(5000);
     }*/

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setMaxPageSize(5000);
   policyMap.setDefaultEntry(defaultEntry);
   broker.setDestinationPolicy(policyMap);

   broker.start();
}
 
Example #6
Source File: NioQueueSubscriptionTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService answer = BrokerFactory.createBroker(new URI("broker://nio://localhost:62621?useQueueForAccept=false&persistent=false&wiewformat.maxInactivityDuration=0"));
   answer.getManagementContext().setCreateConnector(false);
   answer.setUseJmx(false);
   answer.setDeleteAllMessagesOnStartup(true);
   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   entry.setOptimizedDispatch(true);
   policyEntries.add(entry);

   final PolicyMap policyMap = new PolicyMap();
   policyMap.setPolicyEntries(policyEntries);
   answer.setDestinationPolicy(policyMap);
   return answer;
}
 
Example #7
Source File: AdvisoryTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void configureBroker(BrokerService answer) throws Exception {
   answer.setPersistent(false);
   PolicyEntry policy = new PolicyEntry();
   policy.setAdvisoryForFastProducers(true);
   policy.setAdvisoryForConsumed(true);
   policy.setAdvisoryForDelivery(true);
   policy.setAdvisoryForDiscardingMessages(true);
   policy.setAdvisoryForSlowConsumers(true);
   policy.setAdvisoryWhenFull(true);
   policy.setProducerFlowControl(false);
   ConstantPendingMessageLimitStrategy strategy = new ConstantPendingMessageLimitStrategy();
   strategy.setLimit(10);
   policy.setPendingMessageLimitStrategy(strategy);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);

   answer.setDestinationPolicy(pMap);
   answer.addConnector(bindAddress);
   answer.setDeleteAllMessagesOnStartup(true);
}
 
Example #8
Source File: AdvisoryTempDestinationTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void configureBroker(BrokerService answer) throws Exception {
   answer.setPersistent(false);
   ConstantPendingMessageLimitStrategy strategy = new ConstantPendingMessageLimitStrategy();
   strategy.setLimit(10);
   PolicyEntry tempQueueEntry = createPolicyEntry(strategy);
   tempQueueEntry.setTempQueue(true);
   PolicyEntry tempTopicEntry = createPolicyEntry(strategy);
   tempTopicEntry.setTempTopic(true);

   PolicyMap pMap = new PolicyMap();
   final List<PolicyEntry> policyEntries = new ArrayList<>();
   policyEntries.add(tempQueueEntry);
   policyEntries.add(tempTopicEntry);
   pMap.setPolicyEntries(policyEntries);

   answer.setDestinationPolicy(pMap);
   answer.addConnector(bindAddress);
   answer.setDeleteAllMessagesOnStartup(true);
}
 
Example #9
Source File: SimpleNonPersistentQueueTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureBroker(BrokerService answer, String uri) throws Exception {
   // answer.setPersistent(false);
   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   entry.setMemoryLimit(1024 * 1024 * 1); // Set to 1 MB
   entry.setOptimizedDispatch(true);
   entry.setLazyDispatch(true);
   policyEntries.add(entry);

   final PolicyMap policyMap = new PolicyMap();
   policyMap.setPolicyEntries(policyEntries);
   answer.setDestinationPolicy(policyMap);
   super.configureBroker(answer, uri);
}
 
Example #10
Source File: SimpleNonPersistentQueueNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureBroker(BrokerService answer) throws Exception {
   answer.setPersistent(false);
   answer.setMonitorConnectionSplits(true);
   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   entry.setMemoryLimit(1024 * 1024 * 100); // Set to 1 MB
   entry.setOptimizedDispatch(true);
   entry.setProducerFlowControl(true);
   entry.setMaxPageSize(10);
   entry.setLazyDispatch(false);
   policyEntries.add(entry);

   final PolicyMap policyMap = new PolicyMap();
   policyMap.setPolicyEntries(policyEntries);
   answer.setDestinationPolicy(policyMap);
   super.configureBroker(answer);
}
 
Example #11
Source File: PerDurableConsumerDeadLetterTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();

   PolicyEntry policy = new PolicyEntry();
   IndividualDeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
   strategy.setProcessNonPersistent(true);
   strategy.setDestinationPerDurableSubscriber(true);
   policy.setDeadLetterStrategy(strategy);

   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);

   broker.setDestinationPolicy(pMap);

   return broker;
}
 
Example #12
Source File: MessageGroupDelayedTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setPersistent(false);
   service.setUseJmx(false);

   // Setup a destination policy where it takes only 1 message at a time.
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   log.info("testing with consumersBeforeDispatchStarts=" + consumersBeforeDispatchStarts + " and timeBeforeDispatchStarts=" + timeBeforeDispatchStarts);
   policy.setConsumersBeforeDispatchStarts(consumersBeforeDispatchStarts);
   policy.setTimeBeforeDispatchStarts(timeBeforeDispatchStarts);
   policyMap.setDefaultEntry(policy);
   service.setDestinationPolicy(policyMap);

   connector = service.addConnector("tcp://localhost:0");
   return service;
}
 
Example #13
Source File: AbortSlowAckConsumer2Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   AbortSlowAckConsumerStrategy strategy = new AbortSlowAckConsumerStrategy();
   strategy.setAbortConnection(abortConnection);
   strategy.setCheckPeriod(checkPeriod);
   strategy.setMaxSlowDuration(maxSlowDuration);
   strategy.setMaxTimeSinceLastAck(maxTimeSinceLastAck);

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example #14
Source File: IndividualDeadLetterTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();

   PolicyEntry policy = new PolicyEntry();
   DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
   strategy.setProcessNonPersistent(true);
   policy.setDeadLetterStrategy(strategy);

   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);

   broker.setDestinationPolicy(pMap);

   return broker;
}
 
Example #15
Source File: AbortSlowAckConsumer0Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   strategy = createSlowConsumerStrategy();
   underTest = strategy;

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example #16
Source File: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
@Override public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());

    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);

    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();

    plc.setQueuePrefetch(1);

    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);

    broker.start(true);

    connFactory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI());
}
 
Example #17
Source File: DiscardingDeadLetterPolicyTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();

   PolicyEntry policy = new PolicyEntry();
   DeadLetterStrategy strategy = new DiscardingDeadLetterStrategy();
   strategy.setProcessNonPersistent(true);
   policy.setDeadLetterStrategy(strategy);

   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);

   broker.setDestinationPolicy(pMap);

   return broker;
}
 
Example #18
Source File: MessageGroupConfigTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public MessageGroupMap doTestGroupConfiguration(String type, Class classType) throws Exception {
   broker = new BrokerService();

   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setMessageGroupMapFactoryType(type);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(defaultEntry);
   broker.setDestinationPolicy(policyMap);
   broker.start();
   super.topic = false;
   ActiveMQDestination destination = (ActiveMQDestination) createDestination("org.apache.foo");
   Queue brokerDestination = (Queue) broker.getDestination(destination);

   assertNotNull(brokerDestination);
   MessageGroupMap messageGroupMap = brokerDestination.getMessageGroupOwners();
   assertNotNull(messageGroupMap);
   assertTrue(messageGroupMap.getClass().isAssignableFrom(classType));
   return messageGroupMap;
}
 
Example #19
Source File: RequestReplyNoAdvisoryNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService configureBroker(String brokerName) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName(brokerName);
   broker.setAdvisorySupport(false);
   broker.setPersistent(false);
   broker.setUseJmx(false);
   broker.setSchedulePeriodForDestinationPurge(1000);
   broker.setAllowTempAutoCreationOnSend(true);

   PolicyMap map = new PolicyMap();
   PolicyEntry tempReplyQPolicy = new PolicyEntry();
   tempReplyQPolicy.setOptimizedDispatch(true);
   tempReplyQPolicy.setGcInactiveDestinations(true);
   tempReplyQPolicy.setGcWithNetworkConsumers(true);
   tempReplyQPolicy.setInactiveTimeoutBeforeGC(1000);
   map.put(replyQWildcard, tempReplyQPolicy);
   broker.setDestinationPolicy(map);

   broker.addConnector("tcp://localhost:0");
   brokers.add(broker);
   return broker;
}
 
Example #20
Source File: StoreBasedCursorTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void configureBroker(long memoryLimit, long systemLimit) throws Exception {
   broker.setDeleteAllMessagesOnStartup(true);
   broker.addConnector(bindAddress);
   broker.setPersistent(true);

   SystemUsage systemUsage = broker.getSystemUsage();
   systemUsage.setSendFailIfNoSpace(true);
   systemUsage.getMemoryUsage().setLimit(systemLimit);

   PolicyEntry policy = new PolicyEntry();
   policy.setProducerFlowControl(true);
   policy.setUseCache(true);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
}
 
Example #21
Source File: DiscriminatingConsumerLoadTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
   broker = new BrokerService();
   broker.setPersistent(false);

   // workaround is to ensure sufficient dispatch buffer for the destination
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultPolicy = new PolicyEntry();
   defaultPolicy.setMaxPageSize(testSize);
   policyMap.setDefaultEntry(defaultPolicy);
   broker.setDestinationPolicy(policyMap);
   broker.start();

   super.setUp();
   this.producerConnection = this.createConnection();
   this.consumerConnection = this.createConnection();
}
 
Example #22
Source File: PerDestinationStoreLimitTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setDeleteAllMessagesOnStartup(true);

   service.setUseJmx(false);

   service.getSystemUsage().getStoreUsage().setLimit(200 * 1024);

   // allow destination to use 50% of store, leaving 50% for DLQ.
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setStoreUsageHighWaterMark(50);
   policyMap.put(queueDest, policy);
   policyMap.put(topicDest, policy);
   service.setDestinationPolicy(policyMap);

   connector = service.addConnector("tcp://localhost:0");
   return service;
}
 
Example #23
Source File: QueueBrowsingLimitTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   broker = createBroker();
   TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
   broker.deleteAllMessages();
   broker.start();
   broker.waitUntilStarted();

   PolicyEntry policy = new PolicyEntry();
   policy.setMaxBrowsePageSize(browserLimit);
   broker.setDestinationPolicy(new PolicyMap());
   broker.getDestinationPolicy().setDefaultEntry(policy);

   connectUri = connector.getConnectUri();
   factory = new ActiveMQConnectionFactory(connectUri);

}
 
Example #24
Source File: QueueBrowsingTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   broker = createBroker();
   TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
   broker.deleteAllMessages();
   broker.start();
   broker.waitUntilStarted();

   PolicyEntry policy = new PolicyEntry();
   policy.setMaxPageSize(maxPageSize);
   broker.setDestinationPolicy(new PolicyMap());
   broker.getDestinationPolicy().setDefaultEntry(policy);

   connectUri = connector.getConnectUri();
   factory = new ActiveMQConnectionFactory(connectUri);
}
 
Example #25
Source File: MemoryLimitTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.getSystemUsage().getMemoryUsage().setLimit(1 * 1024 * 1024); //1MB
   broker.deleteAllMessages();

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setProducerFlowControl(false);
   policyMap.put(new ActiveMQQueue(">"), policyEntry);
   broker.setDestinationPolicy(policyMap);

   LOG.info("Starting broker with persistenceAdapterChoice " + persistenceAdapterChoice.toString());
   setPersistenceAdapter(broker, persistenceAdapterChoice);
   broker.getPersistenceAdapter().deleteAllMessages();

   return broker;
}
 
Example #26
Source File: ConcurrentProducerQueueConsumerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService brokerService = new BrokerService();
   brokerService.setEnableStatistics(false);
   brokerService.addConnector("tcp://0.0.0.0:0");
   brokerService.setDeleteAllMessagesOnStartup(true);

   PolicyEntry policy = new PolicyEntry();
   policy.setPrioritizedMessages(true);
   policy.setMaxPageSize(500);

   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(policy);
   brokerService.setDestinationPolicy(policyMap);
   setDefaultPersistenceAdapter(brokerService);

   return brokerService;
}
 
Example #27
Source File: MessageGroupReconnectDistributionTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected BrokerService createBroker() throws Exception {
   BrokerService service = new BrokerService();
   service.setAdvisorySupport(false);
   service.setPersistent(false);
   service.setUseJmx(true);

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setUseConsumerPriority(consumerPriority);
   policy.setMessageGroupMapFactoryType("cached?cacheSize=" + (numConsumers - 1));
   policyMap.setDefaultEntry(policy);
   service.setDestinationPolicy(policyMap);

   connector = service.addConnector("tcp://localhost:0");
   return service;
}
 
Example #28
Source File: TopicSubscriptionSlowConsumerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("localhost");
   broker.setUseJmx(true);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.addConnector("vm://localhost");

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setAdvisoryForSlowConsumers(true);

   policyMap.setDefaultEntry(defaultEntry);

   broker.setDestinationPolicy(policyMap);
   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example #29
Source File: ExpiredMessagesTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private BrokerService createBroker(boolean deleteAllMessages, long expireMessagesPeriod) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("localhost");
   broker.setDestinations(new ActiveMQDestination[]{destination});
   broker.setPersistenceAdapter(new MemoryPersistenceAdapter());

   PolicyEntry defaultPolicy = new PolicyEntry();
   if (useVMCursor) {
      defaultPolicy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
   }
   defaultPolicy.setExpireMessagesPeriod(expireMessagesPeriod);
   defaultPolicy.setMaxExpirePageSize(1200);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(defaultPolicy);
   broker.setDestinationPolicy(policyMap);
   broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
   broker.addConnector("tcp://localhost:0");
   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example #30
Source File: QueueMemoryFullMultiBrokersTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void applyMemoryLimitPolicy(BrokerService broker) {
   final SystemUsage memoryManager = new SystemUsage();
   memoryManager.getMemoryUsage().setLimit(1024 * 50); // 50 MB
   broker.setSystemUsage(memoryManager);

   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   entry.setMemoryLimit(1024 * 4); // Set to 2 kb
   entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
   policyEntries.add(entry);

   final PolicyMap policyMap = new PolicyMap();
   policyMap.setPolicyEntries(policyEntries);
   broker.setDestinationPolicy(policyMap);

}