org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy

Here are the examples of the java api class org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy taken from open source projects.

1. AdvisoryTempDestinationTests#configureBroker()

View license
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);
}

2. AdvisoryTests#configureBroker()

Project: activemq-artemis
Source File: AdvisoryTests.java
View license
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);
}

3. UniquePropertyMessageEvictionStrategyTest#createBroker()

View license
@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;
}

4. MessageEvictionTest#createBroker()

View license
BrokerService createBroker(PendingSubscriberMessageStoragePolicy pendingSubscriberPolicy) throws Exception {
    BrokerService brokerService = new BrokerService();
    brokerService.addConnector("tcp://localhost:0");
    brokerService.setUseJmx(false);
    brokerService.setDeleteAllMessagesOnStartup(true);
    // spooling to disk early so topic memory limit is not reached
    brokerService.getSystemUsage().getMemoryUsage().setLimit(500 * 1024);
    final List<PolicyEntry> policyEntries = new ArrayList<>();
    final PolicyEntry entry = new PolicyEntry();
    entry.setTopic(">");
    entry.setAdvisoryForDiscardingMessages(true);
    // so consumer does not get over run while blocked limit the prefetch
    entry.setTopicPrefetch(50);
    entry.setPendingSubscriberPolicy(pendingSubscriberPolicy);
    // limit the number of outstanding messages, large enough to use the file store
    // or small enough not to blow memory limit
    int pendingMessageLimit = 50;
    if (pendingSubscriberPolicy instanceof FilePendingSubscriberMessageStoragePolicy) {
        pendingMessageLimit = 500;
    }
    ConstantPendingMessageLimitStrategy pendingMessageLimitStrategy = new ConstantPendingMessageLimitStrategy();
    pendingMessageLimitStrategy.setLimit(pendingMessageLimit);
    entry.setPendingMessageLimitStrategy(pendingMessageLimitStrategy);
    // to keep the limit in check and up to date rather than just the first few, evict some
    OldestMessageEvictionStrategy messageEvictionStrategy = new OldestMessageEvictionStrategy();
    // whether to check expiry before eviction, default limit 1000 is fine as no ttl set in this test
    //messageEvictionStrategy.setEvictExpiredMessagesHighWatermark(1000);
    entry.setMessageEvictionStrategy(messageEvictionStrategy);
    // let evicted messaged disappear
    entry.setDeadLetterStrategy(null);
    policyEntries.add(entry);
    final PolicyMap policyMap = new PolicyMap();
    policyMap.setPolicyEntries(policyEntries);
    brokerService.setDestinationPolicy(policyMap);
    return brokerService;
}