Package org.apache.activemq.command

Examples of org.apache.activemq.command.MessageAck


        // dispatch thread is ready to flush the dispatch list
        clearDispatchList = true;
    }

    void deliverAcks() {
        MessageAck ack = null;
        if (deliveryingAcknowledgements.compareAndSet(false, true)) {
            if (this.optimizeAcknowledge) {
                if (!deliveredMessages.isEmpty()) {
                    MessageDispatch md = deliveredMessages.getFirst();
                    ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, deliveredMessages.size());
                    deliveredMessages.clear();
                    ackCounter = 0;
                }
            }
            if (ack != null) {
                final MessageAck ackToSend = ack;
                if (executorService == null) {
                    executorService = Executors.newSingleThreadExecutor();
                }
                executorService.submit(new Runnable() {
                    public void run() {
View Full Code Here


                if (!deliveredMessages.isEmpty()) {
                    if (optimizeAcknowledge) {
                        if (deliveryingAcknowledgements.compareAndSet(false, true)) {
                            ackCounter++;
                            if (ackCounter >= (info.getCurrentPrefetchSize() * .65)) {
                                MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE,
                                                                deliveredMessages.size());
                                session.asyncSendPacket(ack);
                                ackCounter = 0;
                                deliveredMessages.clear();
                            }
                            deliveryingAcknowledgements.set(false);
                        }
                    } else {
                        MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, deliveredMessages
                            .size());
                        session.asyncSendPacket(ack);
                        deliveredMessages.clear();
                    }
                }
View Full Code Here

        // The delivered message list is only needed for the recover method
        // which is only used with client ack.
        deliveredCounter++;
        if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
            MessageAck ack = new MessageAck(md, ackType, deliveredCounter);
            ack.setTransactionId(session.getTransactionContext().getTransactionId());
            session.asyncSendPacket(ack);
            additionalWindowSize = deliveredCounter;

            // When using DUPS ok, we do a real ack.
            if (ackType == MessageAck.STANDARD_ACK_TYPE) {
View Full Code Here

            return;
        }

        // Acknowledge the last message.
        MessageDispatch lastMd = deliveredMessages.get(0);
        MessageAck ack = new MessageAck(lastMd, MessageAck.STANDARD_ACK_TYPE, deliveredMessages.size());
        if (session.isTransacted()) {
            session.doStartTransaction();
            ack.setTransactionId(session.getTransactionContext().getTransactionId());
        }
        session.asyncSendPacket(ack);

        // Adjust the counters
        deliveredCounter -= deliveredMessages.size();
View Full Code Here

                && lastMd.getMessage().getRedeliveryCounter() > redeliveryPolicy.getMaximumRedeliveries()) {
                // We need to NACK the messages so that they get sent to the
                // DLQ.
                // Acknowledge the last message.
               
                MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size());
                session.asyncSendPacket(ack);
                // ensure we don't filter this as a duplicate
                session.connection.rollbackDuplicate(this, lastMd.getMessage());
                // Adjust the window size.
                additionalWindowSize = Math.max(0, additionalWindowSize - deliveredMessages.size());
                redeliveryDelay = 0;
            } else {
               
                MessageAck ack = new MessageAck(lastMd, MessageAck.REDELIVERED_ACK_TYPE, deliveredMessages.size());
                session.asyncSendPacket(ack);

                // stop the delivery of messages.
                unconsumedMessages.stop();
View Full Code Here

            }
        };
    }

    protected void removeMessage(ConnectionContext c, IndirectMessageReference r) throws IOException {
        MessageAck ack = new MessageAck();
        ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
        ack.setDestination(destination);
        ack.setMessageID(r.getMessageId());
        acknowledge(c, null, ack, r);
        r.drop();
        dropEvent();
    }
View Full Code Here

                    waitStarted();
                    MessageDispatch md = (MessageDispatch)command;
                    serviceRemoteConsumerAdvisory(md.getMessage().getDataStructure());
                    demandConsumerDispatched++;
                    if (demandConsumerDispatched > (demandConsumerInfo.getPrefetchSize() * .75)) {
                        remoteBroker.oneway(new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, demandConsumerDispatched));
                        demandConsumerDispatched = 0;
                    }
                } else if (command.isBrokerInfo()) {
                    lastConnectSucceeded.set(true);
                    remoteBrokerInfo = (BrokerInfo)command;
View Full Code Here

                            // If the message was originally sent using async
                            // send, we will preserve that QOS
                            // by bridging it using an async send (small chance
                            // of message loss).
                            remoteBroker.oneway(message);
                            localBroker.oneway(new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1));
                            dequeueCounter.incrementAndGet();

                        } else {

                            // The message was not sent using async send, so we
                            // should only ack the local
                            // broker when we get confirmation that the remote
                            // broker has received the message.
                            ResponseCallback callback = new ResponseCallback() {
                                public void onCompletion(FutureResponse future) {
                                    try {
                                        Response response = future.getResult();
                                        if (response.isException()) {
                                            ExceptionResponse er = (ExceptionResponse)response;
                                            serviceLocalException(er.getException());
                                        } else {
                                            localBroker.oneway(new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1));
                                            dequeueCounter.incrementAndGet();
                                        }
                                    } catch (IOException e) {
                                        serviceLocalException(e);
                                    }
View Full Code Here

            // the original ack may be a ranged ack, but we are trying to delete
            // a specific
            // message store here so we need to convert to a non ranged ack.
            if (ack.getMessageCount() > 0) {
                // Dup the ack
                MessageAck a = new MessageAck();
                ack.copy(a);
                ack = a;
                // Convert to non-ranged.
                ack.setFirstMessageId(node.getMessageId());
                ack.setLastMessageId(node.getMessageId());
View Full Code Here

                try {
                    QueueMessageReference r = (QueueMessageReference)i.next();

                    // We should only delete messages that can be locked.
                    if (r.lock(LockOwner.HIGH_PRIORITY_LOCK_OWNER)) {
                        MessageAck ack = new MessageAck();
                        ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
                        ack.setDestination(destination);
                        ack.setMessageID(r.getMessageId());
                        acknowledge(c, null, ack, r);
                        r.drop();
                        dropEvent(true);
                    }
                } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.MessageAck

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.