1 18 package org.apache.activemq.command; 19 20 import org.apache.activemq.state.CommandVisitor; 21 22 23 28 public class MessageAck extends BaseCommand { 29 30 public static final byte DATA_STRUCTURE_TYPE=CommandTypes.MESSAGE_ACK; 31 32 38 public static final byte DELIVERED_ACK_TYPE=0; 39 40 43 public static final byte STANDARD_ACK_TYPE=2; 44 45 49 public static final byte POSION_ACK_TYPE=1; 50 51 protected byte ackType; 52 protected ConsumerId consumerId; 53 protected MessageId firstMessageId; 54 protected MessageId lastMessageId; 55 protected ActiveMQDestination destination; 56 protected TransactionId transactionId; 57 protected int messageCount; 58 59 protected transient String consumerKey; 60 61 public MessageAck() { 62 } 63 64 public MessageAck(MessageDispatch md, byte ackType, int messageCount) { 65 this.ackType = ackType; 66 this.consumerId = md.getConsumerId(); 67 this.destination = md.getDestination(); 68 this.lastMessageId = md.getMessage().getMessageId(); 69 this.messageCount=messageCount; 70 } 71 72 public void copy(MessageAck copy) { 73 super.copy(copy); 74 copy.firstMessageId = firstMessageId; 75 copy.lastMessageId = lastMessageId; 76 copy.destination = destination; 77 copy.transactionId = transactionId; 78 copy.ackType = ackType; 79 copy.consumerId = consumerId; 80 } 81 82 83 public byte getDataStructureType() { 84 return DATA_STRUCTURE_TYPE; 85 } 86 87 public boolean isMessageAck() { 88 return true; 89 } 90 91 public boolean isPoisonAck() { 92 return ackType==POSION_ACK_TYPE; 93 } 94 95 public boolean isStandardAck() { 96 return ackType==STANDARD_ACK_TYPE; 97 } 98 99 public boolean isDeliveredAck() { 100 return ackType==DELIVERED_ACK_TYPE; 101 } 102 103 106 public ActiveMQDestination getDestination() { 107 return destination; 108 } 109 public void setDestination(ActiveMQDestination destination) { 110 this.destination = destination; 111 } 112 113 116 public TransactionId getTransactionId() { 117 return transactionId; 118 } 119 public void setTransactionId(TransactionId transactionId) { 120 this.transactionId = transactionId; 121 } 122 123 public boolean isInTransaction() { 124 return transactionId!=null; 125 } 126 127 130 public ConsumerId getConsumerId() { 131 return consumerId; 132 } 133 public void setConsumerId(ConsumerId consumerId) { 134 this.consumerId = consumerId; 135 } 136 137 140 public byte getAckType() { 141 return ackType; 142 } 143 public void setAckType(byte ackType) { 144 this.ackType = ackType; 145 } 146 147 150 public MessageId getFirstMessageId() { 151 return firstMessageId; 152 } 153 public void setFirstMessageId(MessageId firstMessageId) { 154 this.firstMessageId = firstMessageId; 155 } 156 157 160 public MessageId getLastMessageId() { 161 return lastMessageId; 162 } 163 public void setLastMessageId(MessageId lastMessageId) { 164 this.lastMessageId = lastMessageId; 165 } 166 167 171 public int getMessageCount() { 172 return messageCount; 173 } 174 public void setMessageCount(int messageCount) { 175 this.messageCount = messageCount; 176 } 177 178 public Response visit(CommandVisitor visitor) throws Exception { 179 return visitor.processMessageAck( this ); 180 } 181 182 185 public void setMessageID(MessageId messageID) { 186 setFirstMessageId(messageID); 187 setLastMessageId(messageID); 188 setMessageCount(1); 189 } 190 191 } 192 | Popular Tags |