@Override public void beforeEnd() throws Exception { // validate our consumer so we don't push stale acks that get ignored if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { LOG.debug("forcing rollback - {} consumer no longer active on {}", ack, connection); throw new TransactionRolledBackException("consumer " + ack.getConsumerId() + " no longer active on " + connection); } LOG.trace("beforeEnd ack {}", ack); sendAck(ack); }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
@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()); }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
private Transaction getActiveTransaction(Command command) { Transaction transaction = null; try { if (command instanceof Message) { Message messageSend = (Message) command; ProducerId producerId = messageSend.getProducerId(); ProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId); transaction = producerExchange.getConnectionContext().getTransactions().get(messageSend.getTransactionId()); } else if (command instanceof MessageAck) { MessageAck messageAck = (MessageAck) command; ConsumerBrokerExchange consumerExchange = getConsumerBrokerExchange(messageAck.getConsumerId()); if (consumerExchange != null) { transaction = consumerExchange.getConnectionContext().getTransactions().get(messageAck.getTransactionId()); } } } catch(Exception ignored){ LOG.trace("failed to find active transaction for command: " + command, ignored); } return transaction; }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
LOG.debug("No redelivery of {} on rollback of {} due to failover of {}", md, ack.getTransactionId(), connection.getTransport()); return; if (ack.getTransactionId().isXATransaction() && !connection.hasDispatcher(ack.getConsumerId())) { LOG.debug("No local redelivery of {} on rollback of {} because consumer is no longer active on {}", md, ack.getTransactionId(), connection.getTransport()); return;
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { MessageAck info = (MessageAck)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getFirstMessageId(), bs); rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getLastMessageId(), bs); return rc + 5; }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }
/** * Write a object instance to data output stream * * @param o the instance to be marshaled * @param dataOut the output stream * @throws IOException thrown if an error occurs */ public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { super.tightMarshal2(wireFormat, o, dataOut, bs); MessageAck info = (MessageAck)o; tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs); tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs); tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs); dataOut.writeByte(info.getAckType()); tightMarshalNestedObject2(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut, bs); tightMarshalNestedObject2(wireFormat, (DataStructure)info.getLastMessageId(), dataOut, bs); dataOut.writeInt(info.getMessageCount()); }
/** * Write the booleans that this object uses to a BooleanStream */ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException { MessageAck info = (MessageAck)o; super.looseMarshal(wireFormat, o, dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut); looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut); dataOut.writeByte(info.getAckType()); looseMarshalNestedObject(wireFormat, (DataStructure)info.getFirstMessageId(), dataOut); looseMarshalNestedObject(wireFormat, (DataStructure)info.getLastMessageId(), dataOut); dataOut.writeInt(info.getMessageCount()); } }