Java Code Examples for org.apache.activemq.broker.region.policy.PolicyMap#setPolicyEntries()
The following examples show how to use
org.apache.activemq.broker.region.policy.PolicyMap#setPolicyEntries() .
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 |
@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 |
@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: AdvisoryTempDestinationTests.java From activemq-artemis with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: NioQueueSubscriptionTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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 5
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 6
Source File: UniquePropertyMessageEvictionStrategyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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; }
Example 7
Source File: TopicProducerFlowControlTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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 8
Source File: AMQStackOverFlowTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private BrokerService createBrokerService(final String brokerName, final String uri1, final String uri2) throws Exception { final BrokerService brokerService = new BrokerService(); brokerService.setBrokerName(brokerName); brokerService.setPersistent(false); brokerService.setUseJmx(true); final SystemUsage memoryManager = new SystemUsage(); //memoryManager.getMemoryUsage().setLimit(10); brokerService.setSystemUsage(memoryManager); final List<PolicyEntry> policyEntries = new ArrayList<>(); final PolicyEntry entry = new PolicyEntry(); entry.setQueue(">"); //entry.setMemoryLimit(1); policyEntries.add(entry); final PolicyMap policyMap = new PolicyMap(); policyMap.setPolicyEntries(policyEntries); brokerService.setDestinationPolicy(policyMap); final TransportConnector tConnector = new TransportConnector(); tConnector.setUri(new URI(uri1)); tConnector.setName(brokerName + ".transportConnector"); brokerService.addConnector(tConnector); if (uri2 != null) { final NetworkConnector nc = new DiscoveryNetworkConnector(new URI("static:" + uri2)); nc.setBridgeTempDestinations(true); nc.setBrokerName(brokerName); //nc.setPrefetchSize(1); brokerService.addNetworkConnector(nc); } return brokerService; }
Example 9
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 10
Source File: BrokerExtension.java From james-project with Apache License 2.0 | 5 votes |
private static void enablePrioritySupport(BrokerService aBroker, String queueName) { PolicyMap pMap = new PolicyMap(); PolicyEntry entry = new PolicyEntry(); entry.setPrioritizedMessages(true); entry.setQueue(queueName); pMap.setPolicyEntries(ImmutableList.of(entry)); aBroker.setDestinationPolicy(pMap); }
Example 11
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; }