Java Code Examples for org.apache.activemq.broker.region.policy.PolicyEntry#setPendingQueuePolicy()
The following examples show how to use
org.apache.activemq.broker.region.policy.PolicyEntry#setPendingQueuePolicy() .
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: QueueMemoryFullMultiBrokersTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void applyMemoryLimitPolicy(BrokerService broker) { final SystemUsage memoryManager = new SystemUsage(); memoryManager.getMemoryUsage().setLimit(1024 * 50); // 50 MB broker.setSystemUsage(memoryManager); final List<PolicyEntry> policyEntries = new ArrayList<>(); final PolicyEntry entry = new PolicyEntry(); entry.setQueue(">"); entry.setMemoryLimit(1024 * 4); // Set to 2 kb entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy()); policyEntries.add(entry); final PolicyMap policyMap = new PolicyMap(); policyMap.setPolicyEntries(policyEntries); broker.setDestinationPolicy(policyMap); }
Example 2
Source File: ExpiredMessagesTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
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 3
Source File: CursorQueueStoreTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void configureBroker(BrokerService answer) throws Exception { PolicyEntry policy = new PolicyEntry(); policy.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy()); PolicyMap pMap = new PolicyMap(); pMap.setDefaultEntry(policy); answer.setDestinationPolicy(pMap); answer.setDeleteAllMessagesOnStartup(true); answer.addConnector(bindAddress); answer.setDeleteAllMessagesOnStartup(true); }
Example 4
Source File: QueuePurgeTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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 5
Source File: RecoverExpiredMessagesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected PolicyEntry getDefaultPolicy() { PolicyEntry policy = super.getDefaultPolicy(); policy.setPendingQueuePolicy(queuePendingPolicy); policy.setExpireMessagesPeriod(0); return policy; }
Example 6
Source File: ExpiredMessagesWithNoConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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: UnlimitedEnqueueTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Before public void createBrokerService() throws Exception { brokerService = new BrokerService(); brokerService.setDeleteAllMessagesOnStartup(true); brokerService.setAdvisorySupport(false); // optional, reduce the usage limit so that spooling will occur faster brokerService.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024); brokerService.getSystemUsage().getTempUsage().setLimit((numMessages * payLoadSize) + (1000 * payLoadSize)); PolicyMap policyMap = new PolicyMap(); List<PolicyEntry> entries = new ArrayList<>(); PolicyEntry policy = new PolicyEntry(); // NB: ensure queue cursor limit is below the default 70% usage that the destination will use // if they are the same, the queue memory limit and flow control will kick in first policy.setCursorMemoryHighWaterMark(20); // on by default //policy.setProducerFlowControl(true); policy.setQueue(">"); // policy that will spool references to disk policy.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy()); entries.add(policy); policyMap.setPolicyEntries(entries); brokerService.setDestinationPolicy(policyMap); brokerService.start(); }
Example 8
Source File: JmsProducerFlowControlFailIfNoSpaceTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@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); }
Example 9
Source File: ConsumeFromAMQPTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@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 10
Source File: ProducerAndConsumerBench.java From qpid-jms with Apache License 2.0 | 5 votes |
@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 11
Source File: ProduceToAMQPTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@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); }
Example 12
Source File: NetworkLoadTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected BrokerService createBroker(int brokerId) throws Exception { BrokerService broker = new BrokerService(); broker.setBrokerName("broker-" + brokerId); broker.setPersistent(false); broker.setUseJmx(true); broker.getManagementContext().setCreateConnector(false); final SystemUsage memoryManager = new SystemUsage(); memoryManager.getMemoryUsage().setLimit(1024 * 1024 * 50); // 50 MB broker.setSystemUsage(memoryManager); final List<PolicyEntry> policyEntries = new ArrayList<>(); final PolicyEntry entry = new PolicyEntry(); entry.setQueue(">"); entry.setMemoryLimit(1024 * 1024 * 1); // Set to 1 MB entry.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy()); entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy()); policyEntries.add(entry); // This is to turn of the default behavior of storing topic messages for retroactive consumption final PolicyEntry topicPolicyEntry = new PolicyEntry(); topicPolicyEntry.setTopic(">"); final NoSubscriptionRecoveryPolicy noSubscriptionRecoveryPolicy = new NoSubscriptionRecoveryPolicy(); topicPolicyEntry.setSubscriptionRecoveryPolicy(noSubscriptionRecoveryPolicy); final PolicyMap policyMap = new PolicyMap(); policyMap.setPolicyEntries(policyEntries); broker.setDestinationPolicy(policyMap); TransportConnector transportConnector = new TransportConnector(); transportConnector.setUri(new URI("tcp://localhost:" + (60000 + brokerId))); transportConnector.setDiscoveryUri(new URI("multicast://default?group=" + groupId)); broker.addConnector(transportConnector); DiscoveryNetworkConnector networkConnector = new DiscoveryNetworkConnector(); networkConnector.setUri(new URI("multicast://default?group=" + groupId)); networkConnector.setBridgeTempDestinations(true); networkConnector.setPrefetchSize(1); broker.addNetworkConnector(networkConnector); return broker; }