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

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setPendingSubscriberPolicy() . 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: MessageExpirationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected PolicyEntry getDefaultPolicy() {
   PolicyEntry policy = super.getDefaultPolicy();
   // disable spooling
   policy.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy());
   // have aggressive expiry period to ensure no deadlock or clash
   policy.setExpireMessagesPeriod(100);

   return policy;
}
 
Example 2
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);
}
 
Example 3
Source File: NetworkLoadTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
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;
}