Package org.activemq.service

Examples of org.activemq.service.TransactionTask


            doAdvisoryDispatchMessage(pointer);
        }
        else {           
            messageStore.addMessage(message);           
            // If there is no transaction.. then this executes directly.
            TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask(){
                public void execute() throws Throwable {
                    queue.enqueue(pointer);
                    checkRunning();
                }
            });           
View Full Code Here


            // note that we still need to persist the message even if there are no matching
            // subscribers as they may come along later
            // plus we don't pre-load subscription information               
            final MessageContainer container = getContainer(dest.getPhysicalName());
            container.addMessage(message);
            TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask() {
                public void execute() throws Throwable {
                    doSendMessage(client, message, container);
                }
            });
        }
View Full Code Here

            doAdvisoryDispatchMessage(pointer);
        }
        else {           
            messageStore.addMessage(message);           
            // If there is no transaction.. then this executes directly.
            TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask(){
                public void execute() throws Throwable {
                    queue.enqueue(pointer);
                    checkRunning();
                }
            });           
View Full Code Here

                        pointer.setRedelivered(true);
                    }
                    else {
                        unconsumedMessagesDispatched.decrement();
                        // We may have to undo the delivery..
                        TransactionManager.getContexTransaction().addPostRollbackTask(new TransactionTask() {
                            public void execute() throws Throwable {
                                unconsumedMessagesDispatched.increment();
                                pointer.reset();
                                pointer.setRedelivered(true);
                                dispatch.wakeup(SubscriptionImpl.this);
                            }
                        });
                        final QueueListEntry theEntry = entry;
                        TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask() {
                            public void execute() throws Throwable {
                                messagePtrs.remove(theEntry);
                                if ((ack.isExpired() || ack.isMessageRead()) && !browser) {
                                    if (ack.isExpired() && !pointer.getContainer().isDeadLetterQueue()) {
                                        ActiveMQMessage msg = pointer.getContainer().getMessage(
View Full Code Here

        ActiveMQDestination destination = message.getJMSActiveMQDestination();
        if ( !destination.isQueue() || !message.isTemporary() )
            return;

        // If there is no transaction.. then this executes directly.
        TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask(){
            public void execute() throws Throwable {
                doSendMessage(client, message);
            }
        });
    }
View Full Code Here

        if (!ack.isMessageRead() || ack.isExpired()) {
            redeliverMessage(ts, ack, message);
        } else if (TransactionManager.isCurrentTransaction()) {
            // Hook in a callbacks on first acked message
            if (!ts.hasAckedMessage()) {
                TransactionManager.getContexTransaction().addPostRollbackTask(new TransactionTask() {
                    public void execute() throws Throwable {
                       
                        List ackList = ts.listAckedMessages();
                        HashMap redeliverMap = new HashMap();
                        for (Iterator iter = ackList.iterator(); iter.hasNext();) {
                           
                            ActiveMQMessage message = (ActiveMQMessage) iter.next();
                            message.setJMSRedelivered(true);
                            if (message.incrementDeliveryCount() >= redeliveryPolicy.getMaximumRetryCount()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has exceeded its retry count");
                                }
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else if (ack.isExpired()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has expired");
                                }
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else {
                                Set containers = destinationMap.get(message.getJMSActiveMQDestination());
                                for (Iterator i = containers.iterator();i.hasNext();) {
                                    TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i.next();
                                    LinkedList l = (LinkedList) redeliverMap.get(container);
                                    if( l==null ) {
                                        l = new LinkedList();
                                        redeliverMap.put(container, l);
                                    }
                                    l.add(message);
                                }
                            }
                        }
                       
                        for (Iterator i = redeliverMap.keySet().iterator();i.hasNext();) {
                            TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i.next();
                            List l = (List) redeliverMap.get(container);
                            container.redeliver(l);
                        }
                       
                        ts.removeAllAckedMessages();
                    }
                });
                TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask() {
                    public void execute() throws Throwable {
                        ts.removeAllAckedMessages();
                    }
                });
            }
View Full Code Here

    public void sendMessage(final BrokerClient client, final ActiveMQMessage message) throws JMSException {
        if (TransactionManager.getContexTransaction()==AutoCommitTransaction.AUTO_COMMIT_TRANSACTION){
            doSendMessage(client, message);
        }else {
            // If there is no transaction.. then this executes directly.
            TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask() {
                public void execute() throws Throwable {
                    doSendMessage(client, message);
                }
            });
        }
View Full Code Here

        // Let the message store ack the message.
        messagePointer.getMessageStore().removeMessage(ack);       
        if (TransactionManager.isCurrentTransaction()) {
            // Hook in a callbacks on first acked message
            if (!ts.hasAckedMessage()) {
                TransactionManager.getContexTransaction().addPostRollbackTask(new TransactionTask() {
                    public void execute() throws Throwable {
                       
                        List ackList = ts.listAckedMessages();
                        HashMap redeliverMap = new HashMap();
                       //for (int x = ackList.size()-1; x >= 0 ; x--){   
                       for (int x = 0; x < ackList.size(); x++){   
                            DurableMessagePointer messagePointer = (DurableMessagePointer) ackList.get(x);
                            ActiveMQMessage message = messagePointer.getMessage();
                            message.setJMSRedelivered(true);
                            if (message.incrementDeliveryCount() >= redeliveryPolicy.getMaximumRetryCount()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has exceeded its retry count");
                                }
                                // TODO: see if we can use the deadLetterPolicy of the container that dispatched the message.
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else if (ack.isExpired()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has expired");
                                }
                                // TODO: see if we can use the deadLetterPolicy of the container that dispatched the message.
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else {
                                Set containers = destinationMap.get(message.getJMSActiveMQDestination());
                                for (Iterator i = containers.iterator();i.hasNext();) {
                                    DurableQueueBoundedMessageContainer container = (DurableQueueBoundedMessageContainer) i.next();
                                    LinkedList l = (LinkedList) redeliverMap.get(container);
                                    if( l==null ) {
                                        l = new LinkedList();
                                        redeliverMap.put(container, l);
                                    }
                                    l.add(messagePointer);
                                }
                            }
                        }
                       
                        for (Iterator i = redeliverMap.keySet().iterator();i.hasNext();) {
                            DurableQueueBoundedMessageContainer container = (DurableQueueBoundedMessageContainer) i.next();
                            List l = (List) redeliverMap.get(container);
                            container.redeliver(l);
                        }
                       
                        ts.removeAllAckedMessages();
                    }
                });
                TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask() {
                    public void execute() throws Throwable {
                        ts.removeAllAckedMessages();
                    }
                });
            }
View Full Code Here

                inFlightTxLocations.add(location);
            }
            final Transaction tx = TransactionManager.getContexTransaction();
            JournalAck ack = new JournalAck(destinationName,subscription,messageIdentity.getMessageID(), tx.getTransactionId());
            transactionStore.acknowledge(this, ack, location);
            tx.addPostCommitTask(new TransactionTask(){
                public void execute() throws Throwable {
                    if( debug )
                        log.debug("In flight acknowledge commit: "+messageIdentity.getMessageID()+" at "+location);
                   
                    synchronized (JournalTopicMessageStore.this) {
                        inFlightTxLocations.remove(location);
                        acknowledge(subscription, messageIdentity, location);
                    }
                }
            });
            tx.addPostRollbackTask(new TransactionTask(){
                public void execute() throws Throwable {
                    if( debug )
                        log.debug("In flight acknowledge rollback: "+messageIdentity.getMessageID()+" at "+location);
                    // TODO Auto-generated method stub
                    synchronized (JournalTopicMessageStore.this) {
View Full Code Here

                throw xae;
        }

        // Run the prePrepareTasks
        for (Iterator iter = prePrepareTasks.iterator(); iter.hasNext();) {
            TransactionTask r = (TransactionTask) iter.next();
            r.execute();
        }
    }
View Full Code Here

TOP

Related Classes of org.activemq.service.TransactionTask

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.