Package org.activemq.message

Examples of org.activemq.message.MessageAck


                                store.replayAddMessage(msg);
                                transactionCounter++;
                            }
                        }
                        else if (packet instanceof MessageAck) {
                            MessageAck ack = (MessageAck) packet;
                            JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, ack.getDestination().isQueue());
                            if( ack.getTransactionId()!=null ) {
                                transactionStore.removeMessage(store, ack, pos);
                            } else {
                                store.replayRemoveMessage(ack);
                                transactionCounter++;
                            }
                        }
                        else {
                            log.error("Unknown type of packet in transaction log which will be discarded: " + packet);
                        }

                        break;
                    case TX_COMMAND_RECORD_TYPE:
                       
                        TxCommand command = new TxCommand();
                        command.setType(is.readByte());
                        command.setWasPrepared(is.readBoolean());
                        switch(command.getType()) {
                          case TxCommand.LOCAL_COMMIT:
                          case TxCommand.LOCAL_ROLLBACK:
                              command.setTransactionId(is.readUTF());
                              break;
                          default:
                              command.setTransactionId(ActiveMQXid.read(is));
                            break;
                        }
                       
                        // Try to replay the packet.
                        switch(command.getType()) {
                          case TxCommand.XA_PREPARE:
                              transactionStore.replayPrepare(command.getTransactionId());
                              break;
                          case TxCommand.XA_COMMIT:
                          case TxCommand.LOCAL_COMMIT:
                              Tx tx = transactionStore.replayCommit(command.getTransactionId(), command.getWasPrepared());
                              // Replay the committed operations.
                              if( tx!=null) {
                                  tx.getOperations();
                                  for (Iterator iter = tx.getOperations().iterator(); iter.hasNext();) {
                                      TxOperation op = (TxOperation) iter.next();
                                      if( op.operationType == TxOperation.ADD_OPERATION_TYPE ) {
                                          op.store.replayAddMessage((ActiveMQMessage) op.data);
                                      }
                                      if( op.operationType == TxOperation.REMOVE_OPERATION_TYPE) {
                                          op.store.replayRemoveMessage((MessageAck) op.data);
                                      }
                                      if( op.operationType == TxOperation.ACK_OPERATION_TYPE) {
                                          JournalAck ack = (JournalAck) op.data;
                                          ((JournalTopicMessageStore)op.store).replayAcknowledge(ack.getSubscription(), new MessageIdentity(ack.getMessageId()));
                                      }
                                  }
                                  transactionCounter++;
                              }
                              break;
View Full Code Here


        assertEquals("Message text should be equal", messageTexts[i], text);
        assertEquals(messageIds[i], message.getJMSMessageID());
    }

    protected MessageAck createMessageAck(MessageIdentity messageIdentity) {
        MessageAck answer = new MessageAck();
        answer.setConsumerId(idGenerator.generateId());
        answer.setMessageID(messageIdentity.getMessageID());
        answer.setMessageRead(true);
        return answer;
    }
View Full Code Here

        {
            throw new UnsupportedOperationException("Client Acks not yet supported");
        }
        else if (ackMode == AUTO_ACK)
        {
            MessageAck ack = new MessageAck();
            if (format.isInTransaction()) ack.setTransactionIDString(format.getTransactionId());
            ack.setDestination(msg.getJMSActiveMQDestination());
            ack.setConsumerId(consumerId);
            ack.setMessageID(msg.getJMSMessageID());
            ack.setMessageRead(true);
            ack.setSessionId(format.getSessionId());
            ack.setProducerKey(msg.getProducerKey());
            ack.setSequenceNumber(msg.getSequenceNumber());
            ack.setPersistent(msg.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
            format.enqueuePacket(ack);
        }

        out.writeBytes(new FrameBuilder(Stomp.Responses.MESSAGE)
                .addHeader(Stomp.Headers.Message.DESTINATION,
View Full Code Here

                                store.replayAddMessage(msg);
                                transactionCounter++;
                            }
                        }
                        else if (packet instanceof MessageAck) {
                            MessageAck ack = (MessageAck) packet;
                            JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, ack.getDestination().isQueue());
                            if( ack.getTransactionId()!=null ) {
                                transactionStore.removeMessage(store, ack, pos);
                            } else {
                                store.replayRemoveMessage(ack);
                                transactionCounter++;
                            }
                        }
                        else {
                            log.error("Unknown type of packet in transaction log which will be discarded: " + packet);
                        }

                        break;
                    case TX_COMMAND_RECORD_TYPE:
                       
                        TxCommand command = new TxCommand();
                        command.setType(is.readByte());
                        command.setWasPrepared(is.readBoolean());
                        switch(command.getType()) {
                          case TxCommand.LOCAL_COMMIT:
                          case TxCommand.LOCAL_ROLLBACK:
                              command.setTransactionId(is.readUTF());
                              break;
                          default:
                              command.setTransactionId(ActiveMQXid.read(is));
                            break;
                        }
                       
                        // Try to replay the packet.
                        switch(command.getType()) {
                          case TxCommand.XA_PREPARE:
                              transactionStore.replayPrepare(command.getTransactionId());
                              break;
                          case TxCommand.XA_COMMIT:
                          case TxCommand.LOCAL_COMMIT:
                              Tx tx = transactionStore.replayCommit(command.getTransactionId(), command.getWasPrepared());
                              // Replay the committed operations.
                              tx.getOperations();
                              for (Iterator iter = tx.getOperations().iterator(); iter.hasNext();) {
                                  TxOperation op = (TxOperation) iter.next();
                                  if( op.operationType == TxOperation.ADD_OPERATION_TYPE ) {
                                      op.store.replayAddMessage((ActiveMQMessage) op.data);
                                  }
                                  if( op.operationType == TxOperation.REMOVE_OPERATION_TYPE) {
                                      op.store.replayRemoveMessage((MessageAck) op.data);
                                  }
                                  if( op.operationType == TxOperation.ACK_OPERATION_TYPE) {
                                      JournalAck ack = (JournalAck) op.data;
                                      ((JournalTopicMessageStore)op.store).replayAcknowledge(ack.getSubscription(), new MessageIdentity(ack.getMessageId()));
                                  }
                              }
                              transactionCounter++;
                              break;
                          case TxCommand.LOCAL_ROLLBACK:
View Full Code Here

                            catch (Throwable e) {
                                log.error("Recovery Failure: Could not add message: " + msg.getJMSMessageIdentity().getMessageID() + ", reason: " + e, e);
                            }
                        }
                        else if (packet instanceof MessageAck) {
                            MessageAck ack = (MessageAck) packet;
                            JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, ack.getDestination().isQueue());
                            try {
                                // Only remove the message if it has not allready been removed.
                                ActiveMQMessage t = store.getLongTermMessageStore().getMessage(ack.getMessageIdentity());
                                if( t!=null ) {
                                    store.getLongTermMessageStore().removeMessage(ack);
                                    transactionCounter++;
                                }
                            }
                            catch (Throwable e) {
                                log.error("Recovery Failure: Could not remove message: " + ack.getMessageIdentity().getMessageID() + ", reason: " + e, e);
                            }
                        }
                        else {
                            log.error("Unknown type of packet in transaction log which will be discarded: " + packet);
                        }
View Full Code Here

    }
   
    private void doSendMessageAck(ActiveMQMessage message, boolean messageConsumed, boolean messageExpired)
            throws JMSException {
        if (message != null && !message.isAdvisory()) {
            MessageAck ack = new MessageAck();
            ack.setConsumerId(message.getConsumerIdentifer());
            ack.setTransactionId(transactionContext.getTransactionId());
            ack.setExternalMessageId(message.isExternalMessageId());
            ack.setMessageID(message.getJMSMessageID());
            ack.setSequenceNumber(message.getSequenceNumber());
            ack.setProducerKey(message.getProducerKey());
            ack.setMessageRead(messageConsumed);
            ack.setDestination(message.getJMSActiveMQDestination());
            ack.setPersistent(message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
            ack.setExpired(messageExpired);
            ack.setSessionId(getSessionId());
            this.connection.asyncSendPacket(ack);
        }
    }
View Full Code Here

                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
                        case Packet.ACTIVEMQ_MSG_ACK : {
                            MessageAck ack = (MessageAck) packet;
                            consumeMessageAck(ack);
                            break;
                        }
                        case Packet.XA_TRANSACTION_INFO : {
                            XATransactionInfo info = (XATransactionInfo) packet;
View Full Code Here

                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
                        case Packet.ACTIVEMQ_MSG_ACK : {
                            MessageAck ack = (MessageAck) packet;
                            consumeMessageAck(ack);
                            break;
                        }
                        case Packet.XA_TRANSACTION_INFO : {
                            XATransactionInfo info = (XATransactionInfo) packet;
View Full Code Here

    }
   
    private void doSendMessageAck(ActiveMQMessage message, boolean messageConsumed, boolean messageExpired)
            throws JMSException {
        if (message != null && !message.isAdvisory()) {
            MessageAck ack = new MessageAck();
            ack.setConsumerId(message.getConsumerIdentifer());
            ack.setTransactionId(transactionContext.getTransactionId());
            ack.setExternalMessageId(message.isExternalMessageId());
            ack.setMessageID(message.getJMSMessageID());
            ack.setSequenceNumber(message.getSequenceNumber());
            ack.setProducerKey(message.getProducerKey());
            ack.setMessageRead(messageConsumed);
            ack.setDestination(message.getJMSActiveMQDestination());
            ack.setPersistent(message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
            ack.setExpired(messageExpired);
            ack.setSessionId(getSessionId());
            this.connection.asyncSendPacket(ack);
        }
    }
View Full Code Here

                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
                        case Packet.ACTIVEMQ_MSG_ACK : {
                            MessageAck ack = (MessageAck) packet;
                            consumeMessageAck(ack);
                            break;
                        }
                        case Packet.XA_TRANSACTION_INFO : {
                            XATransactionInfo info = (XATransactionInfo) packet;
View Full Code Here

TOP

Related Classes of org.activemq.message.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.