From e05d2975503ee8884cf240a6b362dcb8a3cc8256 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 14 May 2019 10:07:50 -0700 Subject: [PATCH] [Service Bus] Timeout for message settlement should result in rejected promise --- .../service-bus/src/core/messageReceiver.ts | 14 +++++++++++--- .../service-bus/src/session/messageSession.ts | 12 ++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/sdk/servicebus/service-bus/src/core/messageReceiver.ts b/sdk/servicebus/service-bus/src/core/messageReceiver.ts index ddd72cf2d41e..7ee138defa1b 100644 --- a/sdk/servicebus/service-bus/src/core/messageReceiver.ts +++ b/sdk/servicebus/service-bus/src/core/messageReceiver.ts @@ -8,7 +8,8 @@ import { retry, RetryOperationType, RetryConfig, - ConditionErrorNameMapper + ConditionErrorNameMapper, + ErrorNameConditionMapper } from "@azure/amqp-common"; import { Receiver, @@ -880,12 +881,19 @@ export class MessageReceiver extends LinkEntity { log.receiver( "[%s] Disposition for delivery id: %d, did not complete in %d milliseconds. " + - "Hence resolving the promise.", + "Hence rejecting the promise with timeout error.", this._context.namespace.connectionId, delivery.id, messageDispositionTimeout ); - return resolve(); + + const e: AmqpError = { + condition: ErrorNameConditionMapper.ServiceUnavailableError, + description: + "Operation to settle the message has timed out. The disposition of the " + + "message may or may not be successful" + }; + return reject(translate(e)); }, messageDispositionTimeout); this._deliveryDispositionMap.set(delivery.id, { resolve: resolve, diff --git a/sdk/servicebus/service-bus/src/session/messageSession.ts b/sdk/servicebus/service-bus/src/session/messageSession.ts index ff62933011f9..e24bfbd7ed90 100644 --- a/sdk/servicebus/service-bus/src/session/messageSession.ts +++ b/sdk/servicebus/service-bus/src/session/messageSession.ts @@ -14,6 +14,7 @@ import { EventContext, ReceiverOptions, ReceiverEvents, + AmqpError, isAmqpError } from "rhea-promise"; import * as log from "../log"; @@ -937,12 +938,19 @@ export class MessageSession extends LinkEntity { this._deliveryDispositionMap.delete(delivery.id); log.receiver( "[%s] Disposition for delivery id: %d, did not complete in %d milliseconds. " + - "Hence resolving the promise.", + "Hence rejecting the promise with timeout error", this._context.namespace.connectionId, delivery.id, messageDispositionTimeout ); - return resolve(); + + const e: AmqpError = { + condition: ErrorNameConditionMapper.ServiceUnavailableError, + description: + "Operation to settle the message has timed out. The disposition of the " + + "message may or may not be successful" + }; + return reject(translate(e)); }, messageDispositionTimeout); this._deliveryDispositionMap.set(delivery.id, { resolve: resolve,