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

The following examples show how to use org.apache.activemq.broker.region.policy.PolicyEntry#setQueuePrefetch() . 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: IgniteJmsStreamerTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
@Override public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());

    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);

    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();

    plc.setQueuePrefetch(1);

    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);

    broker.start(true);

    connFactory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI());
}
 
Example 2
Source File: AbortSlowAckConsumer1Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   AbortSlowAckConsumerStrategy strategy = new AbortSlowAckConsumerStrategy();
   strategy.setAbortConnection(abortConnection);
   strategy.setCheckPeriod(checkPeriod);
   strategy.setMaxSlowDuration(maxSlowDuration);
   strategy.setMaxTimeSinceLastAck(maxTimeSinceLastAck);

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example 3
Source File: AbortSlowAckConsumer2Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   AbortSlowAckConsumerStrategy strategy = new AbortSlowAckConsumerStrategy();
   strategy.setAbortConnection(abortConnection);
   strategy.setCheckPeriod(checkPeriod);
   strategy.setMaxSlowDuration(maxSlowDuration);
   strategy.setMaxTimeSinceLastAck(maxTimeSinceLastAck);

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example 4
Source File: AbortSlowAckConsumer0Test.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();

   strategy = createSlowConsumerStrategy();
   underTest = strategy;

   policy.setSlowConsumerStrategy(strategy);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example 5
Source File: AbortSlowConsumerBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   BrokerService broker = super.createBroker();
   PolicyEntry policy = new PolicyEntry();
   underTest.setAbortConnection(abortConnection);
   underTest.setCheckPeriod(checkPeriod);
   underTest.setMaxSlowDuration(maxSlowDuration);

   policy.setSlowConsumerStrategy(underTest);
   policy.setQueuePrefetch(10);
   policy.setTopicPrefetch(10);
   PolicyMap pMap = new PolicyMap();
   pMap.setDefaultEntry(policy);
   broker.setDestinationPolicy(pMap);
   return broker;
}
 
Example 6
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 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);
}
 
Example 10
Source File: IgniteMqttStreamerTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
@Override public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());

    // find an available local port
    try (ServerSocket ss = new ServerSocket(0)) {
        port = ss.getLocalPort();
    }

    // create the broker
    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);

    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();

    plc.setQueuePrefetch(1);

    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);

    // add the MQTT transport connector to the broker
    broker.addConnector("mqtt://localhost:" + port);
    broker.setStartAsync(false);
    broker.start(true);

    // create the broker URL
    brokerUrl = "tcp://localhost:" + port;

    // create the client and connect
    client = new MqttClient(brokerUrl, UUID.randomUUID().toString(), new MemoryPersistence());

    client.connect();

    // create mqtt streamer
    dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME);

    streamer = createMqttStreamer(dataStreamer);
}