Package org.apache.activemq.command

Examples of org.apache.activemq.command.MessageAck


            for (int i = 0; i < 4; i++) {
                message = receiveMessage(connection);
                assertNotNull(message);
            }
            MessageAck ack = createAck(consumerInfo, message, 4, MessageAck.STANDARD_ACK_TYPE);
            ack.setTransactionId(txid);
            connection.send(ack);
        }

        // Don't commit
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

        }

    }

    protected void removeMessage(ConnectionContext c, Subscription subs, QueueMessageReference r) throws IOException {
        MessageAck ack = new MessageAck();
        ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
        ack.setDestination(destination);
        ack.setMessageID(r.getMessageId());
        removeMessage(c, subs, r, ack);
    }
View Full Code Here

                // of the problem.
                connection.onClientInternalException(e);
            }

            try {
                MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1);
                ack.setFirstMessageId(md.getMessage().getMessageId());
                doStartTransaction();
                ack.setTransactionId(getTransactionContext().getTransactionId());
                if (ack.getTransactionId() != null) {
                    getTransactionContext().addSynchronization(new Synchronization() {

                        @Override
                        public void afterRollback() throws Exception {
                            md.getMessage().onMessageRolledBack();
                            // ensure we don't filter this as a duplicate
                            connection.rollbackDuplicate(ActiveMQSession.this, md.getMessage());
                            RedeliveryPolicy redeliveryPolicy = connection.getRedeliveryPolicy();
                            int redeliveryCounter = md.getMessage().getRedeliveryCounter();
                            if (redeliveryPolicy.getMaximumRedeliveries() != RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES
                                && redeliveryCounter > redeliveryPolicy.getMaximumRedeliveries()) {
                                // We need to NACK the messages so that they get
                                // sent to the
                                // DLQ.
                                // Acknowledge the last message.
                                MessageAck ack = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1);
                                ack.setFirstMessageId(md.getMessage().getMessageId());
                                asyncSendPacket(ack);
                            } else {

                                MessageAck ack = new MessageAck(md, MessageAck.REDELIVERED_ACK_TYPE, 1);
                                ack.setFirstMessageId(md.getMessage().getMessageId());
                                asyncSendPacket(ack);

                                // Figure out how long we should wait to resend
                                // this message.
                                long redeliveryDelay = redeliveryPolicy.getInitialRedeliveryDelay();
View Full Code Here

      this.transport.oneway(new RemoveInfo(new ConnectionId("2")));
    } catch(Exception e) {
      fail("Should not have failed to remove this unknown connection");
    }

    this.transport.oneway(new MessageAck());
    this.transport.oneway(new ShutdownInfo());
  }
View Full Code Here

  @Test(timeout=30000)
  public void testResponsesSentWhenRequestForIgnoredCommands() throws Exception {
    this.transport = createTransport();
    assertNotNull(failoverTransport);
    MessageAck ack = new MessageAck();
    assertNotNull("Should have received a Response", this.transport.request(ack));
    RemoveInfo info = new RemoveInfo(new ConnectionId("2"));
    assertNotNull("Should have received a Response", this.transport.request(info));
  }
View Full Code Here

        // Auto ack messages when we reach 75% of the prefetch
        deliveredCounter++;
        if (deliveredCounter > (0.75 * info.getPrefetchSize())) {
            try {
                MessageAck ack = new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, deliveredCounter);
                connection.asyncSendPacket(ack);
                deliveredCounter = 0;
            } catch (JMSException e) {
                connection.onClientInternalException(e);
            }
View Full Code Here

            }
            return rc;
        }

        public MessageAck[] getAcks() {
            MessageAck rc[] = new MessageAck[acks.size()];
            int count = 0;
            for (Iterator<RemoveMessageCommand> iter = acks.iterator(); iter.hasNext();) {
                RemoveMessageCommand cmd = iter.next();
                rc[count++] = cmd.getMessageAck();
            }
View Full Code Here

            }
        }
    }

    void deliverAcks() {
        MessageAck ack = null;
        if (deliveryingAcknowledgements.compareAndSet(false, true)) {
            if (isAutoAcknowledgeEach()) {
                synchronized(deliveredMessages) {
                    ack = makeAckForAllDeliveredMessages(MessageAck.STANDARD_ACK_TYPE);
                    if (ack != null) {
                        deliveredMessages.clear();
                        ackCounter = 0;
                    } else {
                        ack = pendingAck;
                        pendingAck = null;
                    }
                }
            } else if (pendingAck != null && pendingAck.isStandardAck()) {
                ack = pendingAck;
                pendingAck = null;
            }
            if (ack != null) {
                final MessageAck ackToSend = ack;

                if (executorService == null) {
                    executorService = Executors.newSingleThreadExecutor();
                }
                executorService.submit(new Runnable() {
View Full Code Here

    private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException {
        // acks accumulate on the broker pending transaction completion to indicate
        // delivery status
        registerSync();
        MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1);
        ack.setTransactionId(session.getTransactionContext().getTransactionId());
        session.syncSendPacket(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.