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

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setExpireMessagesPeriod() . 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: 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 2
Source File: ExpiryHogTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService bs = new BrokerService();
   bs.setDeleteAllMessagesOnStartup(true);
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setExpireMessagesPeriod(5000);
   defaultEntry.setUseCache(false);
   policyMap.setDefaultEntry(defaultEntry);
   bs.setDestinationPolicy(policyMap);

   return bs;
}
 
Example 3
Source File: BrokerNetworkWithStuckMessagesTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void configureBroker(BrokerService broker) {
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setExpireMessagesPeriod(0);
   ConditionalNetworkBridgeFilterFactory filterFactory = new ConditionalNetworkBridgeFilterFactory();
   filterFactory.setReplayWhenNoConsumers(true);
   defaultEntry.setNetworkBridgeFilterFactory(filterFactory);
   policyMap.setDefaultEntry(defaultEntry);
   broker.setDestinationPolicy(policyMap);
}
 
Example 4
Source File: MessageExpirationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected PolicyEntry getDefaultPolicy() {
   PolicyEntry policy = super.getDefaultPolicy();
   // disable spooling
   policy.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy());
   // have aggressive expiry period to ensure no deadlock or clash
   policy.setExpireMessagesPeriod(100);

   return policy;
}
 
Example 5
Source File: RecoverExpiredMessagesTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected PolicyEntry getDefaultPolicy() {
   PolicyEntry policy = super.getDefaultPolicy();
   policy.setPendingQueuePolicy(queuePendingPolicy);
   policy.setExpireMessagesPeriod(0);
   return policy;
}
 
Example 6
Source File: DurableSubscriptionHangTestCase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void startBroker() throws Exception {
   brokerService = new BrokerService();
   brokerService.setDeleteAllMessagesOnStartup(true);
   brokerService.setBrokerName(brokerName);
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setExpireMessagesPeriod(5000);
   policyMap.setDefaultEntry(defaultEntry);
   brokerService.setDestinationPolicy(policyMap);
   brokerService.start();
}
 
Example 7
Source File: VerifyNetworkConsumersDisconnectTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBroker(BrokerService brokerService) {
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setExpireMessagesPeriod(0);
   PolicyMap policyMap = new PolicyMap();
   policyMap.setDefaultEntry(policyEntry);
   brokerService.setDestinationPolicy(policyMap);
}
 
Example 8
Source File: BrowseDLQTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void startBroker() throws Exception {
   brokerService = BrokerFactory.createBroker("broker:()/localhost?deleteAllMessagesOnStartup=true");

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setExpireMessagesPeriod(1000);
   policyMap.setDefaultEntry(policyEntry);
   brokerService.setDestinationPolicy(policyMap);
   brokerService.start();
   brokerService.waitUntilStarted();
}
 
Example 9
Source File: ExpiredMessagesWithNoConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void doCreateBroker(boolean memoryLimit, int expireMessagesPeriod) throws Exception {
   broker = new BrokerService();
   broker.setBrokerName("localhost");
   broker.setUseJmx(true);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.addConnector("tcp://localhost:0");

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setOptimizedDispatch(optimizedDispatch);
   defaultEntry.setExpireMessagesPeriod(expireMessagesPeriod);
   defaultEntry.setMaxExpirePageSize(800);

   defaultEntry.setPendingQueuePolicy(pendingQueuePolicy);

   if (memoryLimit) {
      // so memory is not consumed by DLQ turn if off
      defaultEntry.setDeadLetterStrategy(null);
      defaultEntry.setMemoryLimit(200 * 1000);
   }

   policyMap.setDefaultEntry(defaultEntry);

   broker.setDestinationPolicy(policyMap);
   broker.start();
   broker.waitUntilStarted();

   connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
}
 
Example 10
Source File: ConsumeFromAMQPTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(false);
    policyEntry.setQueuePrefetch(1000);

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}
 
Example 11
Source File: ProducerAndConsumerBench.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(true);
    policyEntry.setQueuePrefetch(1); // ensure no contention on add with
                                     // matched producer/consumer

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}
 
Example 12
Source File: ProduceToAMQPTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService broker) {
    PolicyEntry policyEntry = new PolicyEntry();
    policyEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policyEntry.setPrioritizedMessages(false);
    policyEntry.setExpireMessagesPeriod(0);
    policyEntry.setEnableAudit(false);
    policyEntry.setOptimizedDispatch(true);
    policyEntry.setQueuePrefetch(100);

    PolicyMap policyMap = new PolicyMap();
    policyMap.setDefaultEntry(policyEntry);
    broker.setDestinationPolicy(policyMap);
}