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

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setProducerFlowControl() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: QueuePurgeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void applyBrokerSpoolingPolicy() {
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry defaultEntry = new PolicyEntry();
   defaultEntry.setProducerFlowControl(false);
   PendingQueueMessageStoragePolicy pendingQueuePolicy = new FilePendingQueueMessageStoragePolicy();
   defaultEntry.setPendingQueuePolicy(pendingQueuePolicy);
   policyMap.setDefaultEntry(defaultEntry);
   broker.setDestinationPolicy(policyMap);
}
 
Example 8
Source File: TempTopicProducerFlowControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setDestinationPolicy(BrokerService broker, PolicyMap pm) {
   PolicyEntry tpe = new PolicyEntry();
   tpe.setTempTopic(true);
   tpe.setMemoryLimit(destinationMemLimit);
   tpe.setProducerFlowControl(true);
   tpe.setAdvisoryWhenFull(true);
   pm.setDefaultEntry(tpe);

   broker.setDestinationPolicy(pm);
}
 
Example 9
Source File: TopicProducerFlowControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   // Setup and start the broker
   broker = new BrokerService();
   broker.setBrokerName(brokerName);
   broker.setPersistent(false);
   broker.setSchedulerSupport(false);
   broker.setUseJmx(false);
   broker.setUseShutdownHook(false);
   broker.addConnector(brokerUrl);

   // Setup the destination policy
   PolicyMap pm = new PolicyMap();

   // Setup the topic destination policy
   PolicyEntry tpe = new PolicyEntry();
   tpe.setTopic(">");
   tpe.setMemoryLimit(destinationMemLimit);
   tpe.setProducerFlowControl(true);
   tpe.setAdvisoryWhenFull(true);

   // Setup the topic destination policy
   PolicyEntry qpe = new PolicyEntry();
   qpe.setQueue(">");
   qpe.setMemoryLimit(destinationMemLimit);
   qpe.setProducerFlowControl(true);
   qpe.setQueuePrefetch(1);
   qpe.setAdvisoryWhenFull(true);

   pm.setPolicyEntries(Arrays.asList(new PolicyEntry[]{tpe, qpe}));

   setDestinationPolicy(broker, pm);

   // Start the broker
   broker.start();
   broker.waitUntilStarted();
}
 
Example 10
Source File: JmsProducerFlowControlFailIfNoSpaceTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureBrokerPolicies(BrokerService brokerService) {

    PolicyEntry policy = new PolicyEntry();
    policy.setMemoryLimit(1);
    policy.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy());
    policy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
    policy.setProducerFlowControl(true);

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

    brokerService.setDestinationPolicy(policyMap);
    brokerService.getSystemUsage().setSendFailIfNoSpace(true);
}