Package org.apache.activemq.command

Examples of org.apache.activemq.command.MessageAck


            }
        }
    }
   
    void acknowledge(MessageDispatch md) throws JMSException {
        MessageAck ack = new MessageAck(md,MessageAck.INDIVIDUAL_ACK_TYPE,1);
        session.sendAck(ack);
        synchronized(deliveredMessages){
            deliveredMessages.remove(md);
        }
    }
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());
          ack.setFirstMessageId(firstMsgId);
                    session.sendAck(ack,true);
                    // 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());
                    ack.setFirstMessageId(firstMsgId);
                    session.sendAck(ack,true);
   
                    // stop the delivery of messages.
                    unconsumedMessages.stop();
   
View Full Code Here

        }
        return message;
    }

    protected MessageAck createAck(ConsumerInfo consumerInfo, Message msg, int count, byte ackType) {
        MessageAck ack = new MessageAck();
        ack.setAckType(ackType);
        ack.setConsumerId(consumerInfo.getConsumerId());
        ack.setDestination(msg.getDestination());
        ack.setLastMessageId(msg.getMessageId());
        ack.setMessageCount(count);
        return ack;
    }
View Full Code Here

     * @throws IOException
     */
    protected void acknowledge(final ConnectionContext context, MessageId messageId,
            Location location, String clientId, String subscriptionName)
            throws IOException {
        MessageAck ack = null;
        lock.lock();
        try {
            lastLocation = location;
        }finally {
            lock.unlock();
        }
       
            if (topicReferenceStore.acknowledgeReference(context, clientId,
                    subscriptionName, messageId)) {
                ack = new MessageAck();
                ack.setLastMessageId(messageId);
              
            }
       
        if (ack != null) {
            removeMessage(context, ack);
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

                               remoteBroker.oneway(message);
                              }
                            else{
                              LOG.info("Message not forwarded on to remote, because message came from remote");                              
                            }
                            localBroker.oneway(new MessageAck(md, MessageAck.INDIVIDUAL_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.INDIVIDUAL_ACK_TYPE, 1));
                                            dequeueCounter.incrementAndGet();
                                        }
                                    } catch (IOException e) {
                                        serviceLocalException(e);
                                    }
View Full Code Here

                // Checkpoint the removed messages.
                Iterator<MessageAck> iterator = cpRemovedMessageLocations.iterator();
                while (iterator.hasNext()) {
                    try {
                        MessageAck ack = iterator.next();
                        longTermStore.removeMessage(transactionTemplate.getContext(), ack);
                    } catch (Throwable e) {
                        LOG.debug("Message could not be removed from long term store: " + e.getMessage(), e);
                    }
                }
View Full Code Here

        }

        boolean acked = false;
        for (Iterator<StompSubscription> iter = subscriptionsByConsumerId.values().iterator(); iter.hasNext();) {
            StompSubscription sub = iter.next();
            MessageAck ack = sub.onStompMessageAck(messageId);
            if (ack != null) {
                ack.setTransactionId(activemqTx);
                sendToActiveMQ(ack, createResponseHandler(command));
                acked = true;
                break;
            }
        }
View Full Code Here

        } else if (ackMode == INDIVIDUAL_ACK) {
            synchronized (this) {
                dispatchedMessage.put(message.getJMSMessageID(), message.getMessageId());
            }
        } else if (ackMode == AUTO_ACK) {
            MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1);
            protocolConverter.getTransportFilter().sendToActiveMQ(ack);
        }

        boolean ignoreTransformation = false;
       
View Full Code Here

        if (!dispatchedMessage.containsKey(messageId)) {
            return null;
        }

        MessageAck ack = new MessageAck();
        ack.setDestination(consumerInfo.getDestination());
        ack.setConsumerId(consumerInfo.getConsumerId());

        if (ackMode == CLIENT_ACK) {
            ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
            int count = 0;
            for (Iterator iter = dispatchedMessage.entrySet().iterator(); iter.hasNext();) {

                Map.Entry entry = (Entry)iter.next();
                String id = (String)entry.getKey();
                MessageId msgid = (MessageId)entry.getValue();

                if (ack.getFirstMessageId() == null) {
                    ack.setFirstMessageId(msgid);
                }

                iter.remove();
                count++;

                if (id.equals(messageId)) {
                    ack.setLastMessageId(msgid);
                    break;
                }

            }
            ack.setMessageCount(count);
        }
        else if (ackMode == INDIVIDUAL_ACK) {
            ack.setAckType(MessageAck.INDIVIDUAL_ACK_TYPE);
            MessageId msgid = (MessageId)dispatchedMessage.get(messageId);
            ack.setMessageID(msgid);
            dispatchedMessage.remove(messageId);
        }
        return ack;
    }
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.