Search in sources :

Example 1 with DeadLetterStrategy

use of org.apache.activemq.broker.region.policy.DeadLetterStrategy in project activemq-artemis by apache.

the class DeadLetterTestSupport method createBroker.

protected BrokerService createBroker() throws Exception {
    BrokerService broker = new BrokerService();
    broker.setPersistent(false);
    PolicyEntry policy = new PolicyEntry();
    DeadLetterStrategy defaultDeadLetterStrategy = policy.getDeadLetterStrategy();
    if (defaultDeadLetterStrategy != null) {
        defaultDeadLetterStrategy.setProcessNonPersistent(true);
    }
    PolicyMap pMap = new PolicyMap();
    pMap.setDefaultEntry(policy);
    broker.setDestinationPolicy(pMap);
    return broker;
}
Also used : PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) DeadLetterStrategy(org.apache.activemq.broker.region.policy.DeadLetterStrategy) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 2 with DeadLetterStrategy

use of org.apache.activemq.broker.region.policy.DeadLetterStrategy in project activemq-artemis by apache.

the class DiscardingDeadLetterPolicyTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    BrokerService broker = super.createBroker();
    PolicyEntry policy = new PolicyEntry();
    DeadLetterStrategy strategy = new DiscardingDeadLetterStrategy();
    strategy.setProcessNonPersistent(true);
    policy.setDeadLetterStrategy(strategy);
    PolicyMap pMap = new PolicyMap();
    pMap.setDefaultEntry(policy);
    broker.setDestinationPolicy(pMap);
    return broker;
}
Also used : PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) DeadLetterStrategy(org.apache.activemq.broker.region.policy.DeadLetterStrategy) DiscardingDeadLetterStrategy(org.apache.activemq.broker.region.policy.DiscardingDeadLetterStrategy) DiscardingDeadLetterStrategy(org.apache.activemq.broker.region.policy.DiscardingDeadLetterStrategy) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 3 with DeadLetterStrategy

use of org.apache.activemq.broker.region.policy.DeadLetterStrategy in project activemq-artemis by apache.

the class RequestReplyTempDestRemovalAdvisoryRaceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    responseReceived.set(0);
    respondentSendError.set(0);
    forwardFailures.set(0);
    sendsWithNoConsumers.set(0);
    networkConnectors.clear();
    advisoryConsumerConnections.clear();
    consumerDemandExists = new CountDownLatch(1);
    createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_A + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);
    createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_B + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);
    createBroker(new URI("broker:(tcp://localhost:0)/" + BROKER_C + "?persistent=false&useJmx=false")).setDedicatedTaskRunner(false);
    PolicyMap map = new PolicyMap();
    PolicyEntry defaultEntry = new PolicyEntry();
    defaultEntry.setSendAdvisoryIfNoConsumers(true);
    DeadLetterStrategy deadletterStrategy = new SharedDeadLetterStrategy();
    deadletterStrategy.setProcessNonPersistent(true);
    defaultEntry.setDeadLetterStrategy(deadletterStrategy);
    defaultEntry.setDispatchPolicy(new PriorityDispatchPolicy());
    map.put(new ActiveMQTempTopic(">"), defaultEntry);
    for (BrokerItem item : brokers.values()) {
        item.broker.setDestinationPolicy(map);
    }
}
Also used : PriorityDispatchPolicy(org.apache.activemq.broker.region.policy.PriorityDispatchPolicy) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) ActiveMQTempTopic(org.apache.activemq.command.ActiveMQTempTopic) SharedDeadLetterStrategy(org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy) DeadLetterStrategy(org.apache.activemq.broker.region.policy.DeadLetterStrategy) CountDownLatch(java.util.concurrent.CountDownLatch) SharedDeadLetterStrategy(org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy) URI(java.net.URI) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 4 with DeadLetterStrategy

use of org.apache.activemq.broker.region.policy.DeadLetterStrategy in project activemq-artemis by apache.

the class IndividualDeadLetterTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    BrokerService broker = super.createBroker();
    PolicyEntry policy = new PolicyEntry();
    DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
    strategy.setProcessNonPersistent(true);
    policy.setDeadLetterStrategy(strategy);
    PolicyMap pMap = new PolicyMap();
    pMap.setDefaultEntry(policy);
    broker.setDestinationPolicy(pMap);
    return broker;
}
Also used : IndividualDeadLetterStrategy(org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) IndividualDeadLetterStrategy(org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy) DeadLetterStrategy(org.apache.activemq.broker.region.policy.DeadLetterStrategy) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 5 with DeadLetterStrategy

use of org.apache.activemq.broker.region.policy.DeadLetterStrategy in project activemq-artemis by apache.

the class TimeStampingBrokerPluginTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    TimeStampingBrokerPlugin tsbp = new TimeStampingBrokerPlugin();
    tsbp.setZeroExpirationOverride(expiry);
    tsbp.setTtlCeiling(expiry);
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.setUseJmx(true);
    broker.setPlugins(new BrokerPlugin[] { tsbp });
    tcpConnector = broker.addConnector("tcp://localhost:0");
    // Add policy and individual DLQ strategy
    PolicyEntry policy = new PolicyEntry();
    DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
    strategy.setProcessExpired(true);
    ((IndividualDeadLetterStrategy) strategy).setUseQueueForQueueMessages(true);
    ((IndividualDeadLetterStrategy) strategy).setQueuePrefix("DLQ.");
    strategy.setProcessNonPersistent(true);
    policy.setDeadLetterStrategy(strategy);
    PolicyMap pMap = new PolicyMap();
    pMap.setDefaultEntry(policy);
    broker.setDestinationPolicy(pMap);
    broker.start();
    // Create a ConnectionFactory
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(tcpConnector.getConnectUri());
    // Create a Connection
    connection = connectionFactory.createConnection();
    connection.start();
    // Create a Session
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    // Create the destination Queue
    destination = session.createQueue(queue);
    // Create a MessageProducer from the Session to the Topic or Queue
    producer = session.createProducer(destination);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) IndividualDeadLetterStrategy(org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) IndividualDeadLetterStrategy(org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy) DeadLetterStrategy(org.apache.activemq.broker.region.policy.DeadLetterStrategy) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Aggregations

DeadLetterStrategy (org.apache.activemq.broker.region.policy.DeadLetterStrategy)5 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)5 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)5 BrokerService (org.apache.activemq.broker.BrokerService)4 IndividualDeadLetterStrategy (org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy)2 URI (java.net.URI)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 DiscardingDeadLetterStrategy (org.apache.activemq.broker.region.policy.DiscardingDeadLetterStrategy)1 PriorityDispatchPolicy (org.apache.activemq.broker.region.policy.PriorityDispatchPolicy)1 SharedDeadLetterStrategy (org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy)1 ActiveMQTempTopic (org.apache.activemq.command.ActiveMQTempTopic)1 Before (org.junit.Before)1