protected void doAcknowledge(ConnectionContext context, String subscriptionKey, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setMessageId(messageId.toProducerKey()); command.setTransactionInfo(ack != null ? TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId())) : null); if (ack != null && ack.isUnmatchedAck()) { command.setAck(UNMATCHED); } else { org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); } store(command, false, null, null); }
void updateIndex(Transaction tx, KahaRemoveMessageCommand command, Location ackLocation) throws IOException { StoredDestination sd = getStoredDestination(command.getDestination(), tx); if (!command.hasSubscriptionKey()) { Long sequenceId = sd.messageIdIndex.remove(tx, command.getMessageId()); if (sequenceId != null) { MessageKeys keys = sd.orderIndex.remove(tx, sequenceId); if (keys != null) { sd.locationIndex.remove(tx, keys.location); decrementAndSubSizeToStoreStat(tx, command.getDestination(), keys.location.getSize()); recordAckMessageReferenceLocation(ackLocation, keys.location); metadata.lastUpdate = ackLocation; } else if (LOG.isDebugEnabled()) { LOG.debug("message not found in order index: " + sequenceId + " for: " + command.getMessageId()); LOG.debug("message not found in sequence id index: " + command.getMessageId()); Long sequence = sd.messageIdIndex.get(tx, command.getMessageId()); String subscriptionKey = command.getSubscriptionKey(); if (command.getAck() != UNMATCHED) { sd.orderIndex.get(tx, sequence); byte priority = sd.orderIndex.lastGetPriority(); metadata.lastUpdate = ackLocation; } else if (LOG.isDebugEnabled()) { LOG.debug("on ack, no message sequence exists for id: " + command.getMessageId() + " and sub: " + command.getSubscriptionKey());
@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toProducerKey()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); processRemove(command, ack.getTransactionId()); }
public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException { if (hasTransactionInfo()) { writeMessage(output, 1, getTransactionInfo()); } if (hasDestination()) { writeMessage(output, 2, getDestination()); } if (hasMessageId()) { output.writeString(3, getMessageId()); } if (hasAck()) { output.writeBytes(4, getAck()); } if (hasSubscriptionKey()) { output.writeString(5, getSubscriptionKey()); } }
public KahaRemoveMessageCommand mergeFrom(KahaRemoveMessageCommand other) { if (other.hasTransactionInfo()) { if (hasTransactionInfo()) { getTransactionInfo().mergeFrom(other.getTransactionInfo()); } else { setTransactionInfo(other.getTransactionInfo().clone()); } } if (other.hasDestination()) { if (hasDestination()) { getDestination().mergeFrom(other.getDestination()); } else { setDestination(other.getDestination().clone()); } } if (other.hasMessageId()) { setMessageId(other.getMessageId()); } if (other.hasAck()) { setAck(other.getAck()); } if (other.hasSubscriptionKey()) { setSubscriptionKey(other.getSubscriptionKey()); } return this; }
public static KahaRemoveMessageCommand parseUnframed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException { return new KahaRemoveMessageCommand().mergeUnframed(data).checktInitialized(); }
public static KahaRemoveMessageCommand parseFramed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException { return new KahaRemoveMessageCommand().mergeFramed(data).checktInitialized(); }
public void clear() { super.clear(); clearTransactionInfo(); clearDestination(); clearMessageId(); clearAck(); clearSubscriptionKey(); }
public KahaRemoveMessageCommand clone() { return new KahaRemoveMessageCommand().mergeFrom(this); }
@Override public void recover(TransactionRecoveryListener listener) throws IOException { for (Map.Entry<TransactionId, ArrayList<Operation>> entry : preparedTransactions.entrySet()) { XATransactionId xid = (XATransactionId)entry.getKey(); ArrayList<Message> messageList = new ArrayList<Message>(); ArrayList<MessageAck> ackList = new ArrayList<MessageAck>(); for (Operation op : entry.getValue()) { if( op.getClass() == AddOpperation.class ) { AddOpperation addOp = (AddOpperation)op; Message msg = (Message)wireFormat.unmarshal( new DataInputStream(addOp.getCommand().getMessage().newInput()) ); messageList.add(msg); } else { RemoveOpperation rmOp = (RemoveOpperation)op; MessageAck ack = (MessageAck)wireFormat.unmarshal( new DataInputStream(rmOp.getCommand().getAck().newInput()) ); ackList.add(ack); } } Message[] addedMessages = new Message[messageList.size()]; MessageAck[] acks = new MessageAck[ackList.size()]; messageList.toArray(addedMessages); ackList.toArray(acks); listener.recover(xid, addedMessages, acks); } } @Override
public boolean equals(Object obj) { if( obj==this ) return true; if( obj==null || obj.getClass()!=KahaRemoveMessageCommand.class ) return false; return equals((KahaRemoveMessageCommand)obj); }
public boolean equals(KahaRemoveMessageCommand obj) { if (hasTransactionInfo() ^ obj.hasTransactionInfo() ) return false; if (hasTransactionInfo() && ( !getTransactionInfo().equals(obj.getTransactionInfo()) )) return false; if (hasDestination() ^ obj.hasDestination() ) return false; if (hasDestination() && ( !getDestination().equals(obj.getDestination()) )) return false; if (hasMessageId() ^ obj.hasMessageId() ) return false; if (hasMessageId() && ( !getMessageId().equals(obj.getMessageId()) )) return false; if (hasAck() ^ obj.hasAck() ) return false; if (hasAck() && ( !getAck().equals(obj.getAck()) )) return false; if (hasSubscriptionKey() ^ obj.hasSubscriptionKey() ) return false; if (hasSubscriptionKey() && ( !getSubscriptionKey().equals(obj.getSubscriptionKey()) )) return false; return true; }
public KahaRemoveMessageCommand mergeFrom(KahaRemoveMessageCommand other) { if (other.hasTransactionInfo()) { if (hasTransactionInfo()) { getTransactionInfo().mergeFrom(other.getTransactionInfo()); } else { setTransactionInfo(other.getTransactionInfo().clone()); } } if (other.hasDestination()) { if (hasDestination()) { getDestination().mergeFrom(other.getDestination()); } else { setDestination(other.getDestination().clone()); } } if (other.hasMessageId()) { setMessageId(other.getMessageId()); } if (other.hasAck()) { setAck(other.getAck()); } if (other.hasSubscriptionKey()) { setSubscriptionKey(other.getSubscriptionKey()); } return this; }
public static KahaRemoveMessageCommand parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException { return new KahaRemoveMessageCommand().mergeUnframed(data).checktInitialized(); }
public static KahaRemoveMessageCommand parseFramed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException { return new KahaRemoveMessageCommand().mergeFramed(data).checktInitialized(); }
public void clear() { super.clear(); clearTransactionInfo(); clearDestination(); clearMessageId(); clearAck(); clearSubscriptionKey(); }
public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); command.setMessageId(messageId.toString()); // We are not passed a transaction info.. so we can't participate in a transaction. // Looks like a design issue with the TopicMessageStore interface. Also we can't recover the original ack // to pass back to the XA recover method. // command.setTransactionInfo(); processRemove(command, null); }
public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toString()); processRemove(command, ack.getTransactionId()); }
public KahaRemoveMessageCommand clone() { return new KahaRemoveMessageCommand().mergeFrom(this); }