Repository: activemq Updated Branches: refs/heads/trunk c07514f57 -> da07a1176
https://issues.apache.org/jira/browse/AMQ-4563 Fix for client's that use a message Id similar to ActiveMQ's version which can throw off the ack later on when a stored message is dispatched. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/da07a117 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/da07a117 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/da07a117 Branch: refs/heads/trunk Commit: da07a11760e18edb52035129495edc97193e3fe3 Parents: 6d8449f Author: Timothy Bish <[email protected]> Authored: Thu Mar 27 11:32:57 2014 -0400 Committer: Timothy Bish <[email protected]> Committed: Thu Mar 27 11:33:50 2014 -0400 ---------------------------------------------------------------------- .../transport/amqp/AmqpProtocolConverter.java | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/da07a117/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java ---------------------------------------------------------------------- diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java index 71a26e0..a0560b4 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java @@ -561,14 +561,20 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { } message.setProducerId(producerId); - MessageId messageId = message.getMessageId(); - if (messageId == null) { - messageId = new MessageId(); - message.setMessageId(messageId); + // Always override the AMQP client's MessageId with our own. Preserve the + // original in the TextView property for later Ack. + MessageId messageId = new MessageId(producerId, messageIdGenerator.getNextSequenceId()); + + MessageId amqpMessageId = message.getMessageId(); + if (amqpMessageId != null) { + if (amqpMessageId.getTextView() != null) { + messageId.setTextView(amqpMessageId.getTextView()); + } else { + messageId.setTextView(amqpMessageId.toString()); + } } - messageId.setProducerId(producerId); - messageId.setProducerSequenceId(messageIdGenerator.getNextSequenceId()); + message.setMessageId(messageId); LOG.trace("Inbound Message:{} from Producer:{}", message.getMessageId(), producerId + ":" + messageId.getProducerSequenceId()); @@ -580,12 +586,12 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { } // Lets handle the case where the expiration was set, but the timestamp - // was not set by the client. Lets assign the timestamp now, and adjust the + // was not set by the client. Lets assign the timestamp now, and adjust the // expiration. - if( message.getExpiration()!= 0 ) { - if( message.getTimestamp()==0 ) { + if (message.getExpiration() != 0) { + if (message.getTimestamp() == 0) { message.setTimestamp(System.currentTimeMillis()); - message.setExpiration(message.getTimestamp()+message.getExpiration()); + message.setExpiration(message.getTimestamp() + message.getExpiration()); } }
