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

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setOptimizedDispatch() . 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: 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 3
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 4
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 5
Source File: VirtualTopicNetworkClusterReactivationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private PolicyMap buildPolicyMap() {
   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policyEntry = new PolicyEntry();
   policyEntry.setOptimizedDispatch(true);
   ConditionalNetworkBridgeFilterFactory networkBridgeFilterFactory = new ConditionalNetworkBridgeFilterFactory();
   networkBridgeFilterFactory.setReplayWhenNoConsumers(true);
   policyEntry.setNetworkBridgeFilterFactory(networkBridgeFilterFactory);
   policyEntry.setEnableAudit(false);
   policyMap.put(new ActiveMQQueue("Consumer.*.VirtualTopic.>"), policyEntry);
   return policyMap;
}
 
Example 6
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 7
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 8
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 9
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);
}