Examples of DeadLetterStrategy


Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        brokerService = new BrokerService();

        connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString();

        // Configure Dead Letter Strategy
        DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
        ((IndividualDeadLetterStrategy)strategy).setUseQueueForQueueMessages(true);
        ((IndividualDeadLetterStrategy)strategy).setQueuePrefix("DLQ.");
        strategy.setProcessNonPersistent(false);
        strategy.setProcessExpired(false);

        // Add policy and individual DLQ strategy
        PolicyEntry policy = new PolicyEntry();
        policy.setTimeBeforeDispatchStarts(3000);
        policy.setDeadLetterStrategy(strategy);
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        URI uri = new URI(stompConnectionUri);
        this.port = uri.getPort();

        // 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);
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        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()) {
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

            MessageReference node, Subscription subscription){
        try{
            if(node!=null){
                Message message=node.getMessage();
                if(message!=null && node.getRegionDestination()!=null){
                    DeadLetterStrategy deadLetterStrategy=((Destination)node
                            .getRegionDestination()).getDeadLetterStrategy();
                    if(deadLetterStrategy!=null){
                        if(deadLetterStrategy.isSendToDeadLetterQueue(message)){
                            // message may be inflight to other subscriptions so do not modify
                            message = message.copy();
                            stampAsExpired(message);
                            message.setExpiration(0);
                            if(!message.isPersistent()){
                                message.setPersistent(true);
                                message.setProperty("originalDeliveryMode",
                                        "NON_PERSISTENT");
                            }
                            // The original destination and transaction id do
                            // not get filled when the message is first sent,
                            // it is only populated if the message is routed to
                            // another destination like the DLQ
                            ActiveMQDestination deadLetterDestination=deadLetterStrategy
                                    .getDeadLetterQueueFor(message, subscription);
                            if (context.getBroker()==null) {
                                context.setBroker(getRoot());
                            }
                            BrokerSupport.resendNoCopy(context,message,
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        }
        super.send(producerExchange, message);
    }

    private boolean isDestinationDLQ(Message message) {
        DeadLetterStrategy deadLetterStrategy;
        Message tmp;

        Destination regionDestination = (Destination) message.getRegionDestination();
        if (message != null && regionDestination != null) {
            deadLetterStrategy = regionDestination.getDeadLetterStrategy();
            if (deadLetterStrategy != null) {
                // Cheap copy, since we only need two fields
                tmp = new ActiveMQMessage();
                tmp.setDestination(message.getOriginalDestination());
                tmp.setRegionDestination(regionDestination);

                // Determine if we are headed for a DLQ
                ActiveMQDestination deadLetterDestination = deadLetterStrategy.getDeadLetterQueueFor(tmp, null);
                if (deadLetterDestination.equals(message.getDestination())) {
                    return true;
                }
            }
        }
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

    protected BrokerService createBroker() throws Exception {
        BrokerService broker = new BrokerService();
        broker.setPersistent(false);
        PolicyEntry policy = new PolicyEntry();
        policy.setEnableAudit(false);
        DeadLetterStrategy defaultDeadLetterStrategy = policy.getDeadLetterStrategy();
        if(defaultDeadLetterStrategy!=null) {
            defaultDeadLetterStrategy.setProcessNonPersistent(true);
            ((AbstractDeadLetterStrategy) defaultDeadLetterStrategy).setEnableAudit(false);
        }
        PolicyMap pMap = new PolicyMap();
        pMap.setDefaultEntry(policy);
        broker.setDestinationPolicy(pMap);
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

    public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference node, Subscription subscription, Throwable poisonCause) {
        try {
            if (node != null) {
                Message message = node.getMessage();
                if (message != null && node.getRegionDestination() != null) {
                    DeadLetterStrategy deadLetterStrategy = ((Destination) node.getRegionDestination()).getDeadLetterStrategy();
                    if (deadLetterStrategy != null) {
                        if (deadLetterStrategy.isSendToDeadLetterQueue(message)) {
                            // message may be inflight to other subscriptions so do not modify
                            message = message.copy();
                            stampAsExpired(message);
                            message.setExpiration(0);
                            if (!message.isPersistent()) {
                                message.setPersistent(true);
                                message.setProperty("originalDeliveryMode", "NON_PERSISTENT");
                            }
                            if (poisonCause != null) {
                                message.setProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY,
                                        poisonCause.toString());
                            }
                            // The original destination and transaction id do
                            // not get filled when the message is first sent,
                            // it is only populated if the message is routed to
                            // another destination like the DLQ
                            ActiveMQDestination deadLetterDestination = deadLetterStrategy.getDeadLetterQueueFor(message, subscription);
                            if (context.getBroker() == null) {
                                context.setBroker(getRoot());
                            }
                            BrokerSupport.resendNoCopy(context, message, deadLetterDestination);
                            return true;
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        removeMessage(context, m);
        messagesLock.writeLock().lock();
        try {
            messages.rollback(m.getMessageId());
            if (isDLQ()) {
                DeadLetterStrategy stratagy = getDeadLetterStrategy();
                stratagy.rollback(m.getMessage());
            }
        } finally {
            messagesLock.writeLock().unlock();
        }
        return true;
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

    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);
View Full Code Here

Examples of org.apache.activemq.broker.region.policy.DeadLetterStrategy

        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);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.