Package org.apache.activemq

Examples of org.apache.activemq.RedeliveryPolicy


    private static final Logger LOG = LoggerFactory.getLogger(RedeliveryPluginTest.class);
    RedeliveryPlugin underTest = new RedeliveryPlugin();

    public void testInstallPluginValidation() throws Exception {
        RedeliveryPolicyMap redeliveryPolicyMap = new RedeliveryPolicyMap();
        RedeliveryPolicy defaultEntry = new RedeliveryPolicy();
        defaultEntry.setInitialRedeliveryDelay(500);
        redeliveryPolicyMap.setDefaultEntry(defaultEntry);
        underTest.setRedeliveryPolicyMap(redeliveryPolicyMap);

        final BrokerService brokerService = new BrokerService();
        brokerService.setSchedulerSupport(false);
        Broker broker = new ErrorBroker("hi") {
            @Override
            public BrokerService getBrokerService() {
                return brokerService;
            }
        };

        try {
            underTest.installPlugin(broker);
            fail("expect exception on no scheduler support");
        } catch (Exception expected) {
            LOG.info("expected: " + expected);
        }

        brokerService.setSchedulerSupport(true);
        try {
            underTest.installPlugin(broker);
            fail("expect exception on small initial delay");
        } catch (Exception expected) {
            LOG.info("expected: " + expected);
        }

        defaultEntry.setInitialRedeliveryDelay(5000);
        defaultEntry.setRedeliveryDelay(500);
        brokerService.setSchedulerSupport(true);
        try {
            underTest.installPlugin(broker);
            fail("expect exception on small redelivery delay");
        } catch (Exception expected) {
View Full Code Here


    };

    protected ActiveMQConnectionFactory createConnectionFactory()
            throws Exception {
        ActiveMQConnectionFactory answer = super.createConnectionFactory();
        RedeliveryPolicy policy = new RedeliveryPolicy();
        policy.setMaximumRedeliveries(3);
        policy.setBackOffMultiplier((short) 1);
        policy.setRedeliveryDelay(0);
        policy.setInitialRedeliveryDelay(0);
        policy.setUseExponentialBackOff(false);
        answer.setRedeliveryPolicy(policy);
        return answer;
    }
View Full Code Here

public class NoRetryDeadLetterTest extends DeadLetterTest {
    private static final Logger LOG = LoggerFactory.getLogger(NoRetryDeadLetterTest.class);

    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
        ActiveMQConnectionFactory connectionFactory = super.createConnectionFactory();
        RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
        redeliveryPolicy.setMaximumRedeliveries(0);
        connectionFactory.setRedeliveryPolicy(redeliveryPolicy);
        return connectionFactory;
    }
View Full Code Here

        super.setUp();
    }

    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
        ActiveMQConnectionFactory answer = super.createConnectionFactory();
        RedeliveryPolicy policy = new RedeliveryPolicy();
        policy.setMaximumRedeliveries(3);
        policy.setBackOffMultiplier((short) 1);
        policy.setInitialRedeliveryDelay(10);
        policy.setUseExponentialBackOff(false);
        answer.setRedeliveryPolicy(policy);
        return answer;
    }
View Full Code Here

                connectionFactory = new ActiveMQConnectionFactory(jmsConnectionURI);
                connection = (ActiveMQConnection) connectionFactory.createConnection();
                connection.start();
                session = connection.createSession(true, Session.SESSION_TRANSACTED);

                RedeliveryPolicy policy = connection.getRedeliveryPolicy();
                policy.setInitialRedeliveryDelay(1);
                policy.setUseExponentialBackOff(false);
                policy.setMaximumRedeliveries(maxRedeliveries);

                connection.setExceptionListener(this);

                Destination destination = null;
                if (isTopic) {
View Full Code Here

       
        ActiveMQConnectionFactory factory = applicationContext.getBean("connectionFactory", ActiveMQConnectionFactory.class);
        ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
       
        // send message to dlq immediately
        RedeliveryPolicy policy = connection.getRedeliveryPolicy();
        policy.setMaximumRedeliveries(0);       
        connection.start();
       
        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
        ActiveMQQueue destination = new ActiveMQQueue("camelRedeliveryQ");
        MessageProducer producer = session.createProducer(destination);
View Full Code Here

     * Returns the redelivery policy; not using bean properties to avoid
     * breaking compatibility with JCA configuration in J2EE
     */
    public RedeliveryPolicy redeliveryPolicy() {
        if (redeliveryPolicy == null) {
            redeliveryPolicy = new RedeliveryPolicy();
        }
        return redeliveryPolicy;
    }
View Full Code Here

            }
        }
        ActiveMQConnection physicalConnection = (ActiveMQConnection)connectionFactory.createConnection(userName, password);

        // have we configured a redelivery policy
        RedeliveryPolicy redeliveryPolicy = activationSpec.redeliveryPolicy();
        if (redeliveryPolicy != null) {
            physicalConnection.setRedeliveryPolicy(redeliveryPolicy);
        }
        return physicalConnection;
    }
View Full Code Here

     * by the destination so a delay is vital to avoid resending before it has been consumed
     */
    private void validatePolicyDelay(long limit) {
        final ActiveMQDestination matchAll = new AnyDestination(new ActiveMQDestination[]{new ActiveMQQueue(">"), new ActiveMQTopic(">")});
        for (Object entry : redeliveryPolicyMap.get(matchAll)) {
            RedeliveryPolicy redeliveryPolicy = (RedeliveryPolicy) entry;
            validateLimit(limit, redeliveryPolicy);
        }
        RedeliveryPolicy defaultEntry = redeliveryPolicyMap.getDefaultEntry();
        if (defaultEntry != null) {
            validateLimit(limit, defaultEntry);
        }
    }
View Full Code Here

            // there are two uses of  sendToDeadLetterQueue, we are only interested in valid messages
            return super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
        } else {
            try {
                Destination regionDestination = (Destination) messageReference.getRegionDestination();
                final RedeliveryPolicy redeliveryPolicy = redeliveryPolicyMap.getEntryFor(regionDestination.getActiveMQDestination());
                if (redeliveryPolicy != null) {
                    final int maximumRedeliveries = redeliveryPolicy.getMaximumRedeliveries();
                    int redeliveryCount = messageReference.getRedeliveryCounter();
                    if (RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES == maximumRedeliveries || redeliveryCount < maximumRedeliveries) {

                        long delay = ( redeliveryCount == 0 ?
                                redeliveryPolicy.getInitialRedeliveryDelay() :
                                redeliveryPolicy.getNextRedeliveryDelay(getExistingDelay(messageReference)));

                        scheduleRedelivery(context, messageReference, delay, ++redeliveryCount);
                    } else if (isSendToDlqIfMaxRetriesExceeded()) {
                        return super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
                    } else {
View Full Code Here

TOP

Related Classes of org.apache.activemq.RedeliveryPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.