Examples of MessageAck


Examples of org.apache.activemq.command.MessageAck

    synchronized (deliveredMessages) {
      if (deliveredMessages.isEmpty())
        return null;
         
      MessageDispatch md = deliveredMessages.getFirst();
        MessageAck ack = new MessageAck(md, type, deliveredMessages.size());
        ack.setFirstMessageId(deliveredMessages.getLast().getMessage().getMessageId());
        return ack;
    }
  }
View Full Code Here

Examples of org.apache.activemq.command.MessageAck

        // The delivered message list is only needed for the recover method
        // which is only used with client ack.
        deliveredCounter++;
       
        MessageAck oldPendingAck = pendingAck;
        pendingAck = new MessageAck(md, ackType, deliveredCounter);
        if( oldPendingAck==null ) {
            pendingAck.setFirstMessageId(pendingAck.getLastMessageId());
        } else {
            pendingAck.setFirstMessageId(oldPendingAck.getFirstMessageId());
        }
        pendingAck.setTransactionId(session.getTransactionContext().getTransactionId());

        if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
            session.sendAck(pendingAck);
View Full Code Here

Examples of org.apache.activemq.command.MessageAck

     * @throws JMSException
     */
    public void acknowledge() throws JMSException {
        synchronized(deliveredMessages) {
            // Acknowledge all messages so far.
            MessageAck ack = makeAckForAllDeliveredMessages(MessageAck.STANDARD_ACK_TYPE);
            if (ack == null)
              return; // no msgs
           
            if (session.isTransacted()) {
                session.doStartTransaction();
                ack.setTransactionId(session.getTransactionContext().getTransactionId());
            }
            session.sendAck(ack);
            pendingAck = null;
   
            // Adjust the counters
View Full Code Here

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

Examples of org.apache.activemq.command.MessageAck

                    && 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

Examples of org.apache.activemq.command.MessageAck

        }
        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

Examples of org.apache.activemq.command.MessageAck

     * @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

Examples of org.apache.activemq.command.MessageAck

                    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

Examples of org.apache.activemq.command.MessageAck

                               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

Examples of org.apache.activemq.command.MessageAck

                // 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
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.