From be4b566f4bcddd7101283ef47f2bf04d0459d86d Mon Sep 17 00:00:00 2001 From: Hemant Tanwar Date: Wed, 29 Jul 2020 09:22:08 -0700 Subject: [PATCH] adding missing API for SBRM (#13569) * adding missing API for ServiceBusReceivedMEssage --- .../ServiceBusMessageSerializer.java | 4 ++- .../servicebus/ServiceBusReceivedMessage.java | 32 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessageSerializer.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessageSerializer.java index ed5caf89b1543..a8eac0e245a7c 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessageSerializer.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusMessageSerializer.java @@ -323,7 +323,8 @@ private ServiceBusReceivedMessage deserializeMessage(Message amqpMessage) { brokeredMessage.setDeadLetterReason(String.valueOf(propertiesValue.get(DEAD_LETTER_REASON))); } if (propertiesValue.containsKey(DEAD_LETTER_DESCRIPTION)) { - brokeredMessage.setDeadLetterDescription(String.valueOf(propertiesValue.get(DEAD_LETTER_DESCRIPTION))); + brokeredMessage.setDeadLetterErrorDescription(String.valueOf( + propertiesValue.get(DEAD_LETTER_DESCRIPTION))); } } @@ -385,6 +386,7 @@ private ServiceBusReceivedMessage deserializeMessage(Message amqpMessage) { brokeredMessage.setDeadLetterSource((String) value); break; case ENQUEUED_SEQUENCE_NUMBER: + brokeredMessage.setEnqueuedSequenceNumber((long) value); break; default: logger.info("Unrecognised key: {}, value: {}", key, value); diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusReceivedMessage.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusReceivedMessage.java index 797ed57ba9542..4e925c868369a 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusReceivedMessage.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusReceivedMessage.java @@ -19,6 +19,7 @@ public final class ServiceBusReceivedMessage { private UUID lockToken; private long sequenceNumber; + private long enqueuedSequenceNumber; private long deliveryCount; private Instant enqueuedTime; private Instant lockedUntil; @@ -39,7 +40,7 @@ public final class ServiceBusReceivedMessage { private String to; private String viaPartitionKey; private String deadLetterReason; - private String deadLetterDescription; + private String deadLetterErrorDescription; ServiceBusReceivedMessage(byte[] body) { this.body = Objects.requireNonNull(body, "'body' cannot be null."); @@ -91,8 +92,8 @@ public String getCorrelationId() { * * @return The description for a message that has been dead-lettered. */ - public String getDeadLetterDescription() { - return deadLetterDescription; + public String getDeadLetterErrorDescription() { + return deadLetterErrorDescription; } /** @@ -136,6 +137,21 @@ public long getDeliveryCount() { return deliveryCount; } + /** + * Gets the enqueued sequence number assigned to a message by Service Bus. + *

+ * The sequence number is a unique 64-bit integer first assigned to a message as it is accepted at its original + * point of submission. + * + * @return enqueued sequence number of this message + * + * @see Message Sequencing and + * Timestamps + */ + public long getEnqueuedSequenceNumber() { + return this.enqueuedSequenceNumber; + } + /** * Gets the instant at which this message was enqueued in Azure Service Bus. *

@@ -395,10 +411,10 @@ void setContentType(String contentType) { /** * Sets the dead letter description. * - * @param deadLetterDescription Dead letter description. + * @param deadLetterErrorDescription Dead letter description. */ - void setDeadLetterDescription(String deadLetterDescription) { - this.deadLetterDescription = deadLetterDescription; + void setDeadLetterErrorDescription(String deadLetterErrorDescription) { + this.deadLetterErrorDescription = deadLetterErrorDescription; } /** @@ -430,6 +446,10 @@ void setDeliveryCount(long deliveryCount) { this.deliveryCount = deliveryCount; } + void setEnqueuedSequenceNumber(long enqueuedSequenceNumber) { + this.enqueuedSequenceNumber = enqueuedSequenceNumber; + } + /** * Sets the instant at which this message was enqueued in Azure Service Bus. *