Java Code Examples for org.apache.activemq.broker.region.policy.PolicyEntry#setAdvisoryForDiscardingMessages()

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setAdvisoryForDiscardingMessages() . 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: 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 2
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 3
Source File: AdvisoryTempDestinationTests.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private PolicyEntry createPolicyEntry(ConstantPendingMessageLimitStrategy strategy) {
   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);
   policy.setPendingMessageLimitStrategy(strategy);

   return policy;
}
 
Example 4
Source File: UniquePropertyMessageEvictionStrategyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setTopic(">");

   entry.setAdvisoryForDiscardingMessages(true);
   entry.setTopicPrefetch(1);

   ConstantPendingMessageLimitStrategy pendingMessageLimitStrategy = new ConstantPendingMessageLimitStrategy();
   pendingMessageLimitStrategy.setLimit(10);
   entry.setPendingMessageLimitStrategy(pendingMessageLimitStrategy);

   UniquePropertyMessageEvictionStrategy messageEvictionStrategy = new UniquePropertyMessageEvictionStrategy();
   messageEvictionStrategy.setPropertyName("sequenceI");
   entry.setMessageEvictionStrategy(messageEvictionStrategy);

   // let evicted messages disappear
   entry.setDeadLetterStrategy(null);
   policyEntries.add(entry);

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

   return broker;
}