ServiceBusSessionReceiver interface
A receiver that handles sessions, including renewing the session lock.
- Extends
Properties
session |
The session ID. |
session |
The time in UTC until which the session is locked.
Every time Will return undefined until a AMQP receiver link has been successfully set up for the session. |
Inherited Properties
entity |
Path of the entity for which the receiver has been created. |
identifier | A name used to identify the receiver. This can be used to correlate logs and exceptions. If not specified or empty, a random unique one will be generated. |
is |
Returns |
receive |
The receive mode used to create the receiver. |
Methods
get |
Gets the state of the Session. For more on session states, see Session State |
renew |
Renews the lock on the session. |
set |
Sets the state on the Session. For more on session states, see Session State |
subscribe(Message |
Streams messages to message handlers. |
Inherited Methods
abandon |
The lock held on the message by the receiver is let go, making the message available again in Service Bus for another receive operation. |
close() | Closes the receiver.
Once closed, the receiver cannot be used for any further operations.
Use the |
complete |
Removes the message from Service Bus. |
dead |
Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new QueueClient/SubscriptionClient using the path for the deadletter sub-queue. |
defer |
Defers the processing of the message. Save the |
get |
Returns an iterator that can be used to receive messages from Service Bus. |
peek |
Peek the next batch of active messages (including deferred but not deadlettered messages) on the queue or subscription without modifying them.
|
receive |
Returns a promise that resolves to an array of deferred messages identified by given |
receive |
Returns a promise that resolves to an array of messages received from Service Bus. |
renew |
Renews the lock on the message for the duration as specified during the Queue/Subscription creation.
|
Property Details
sessionId
The session ID.
sessionId: string
Property Value
string
sessionLockedUntilUtc
The time in UTC until which the session is locked.
Every time renewSessionLock()
is called, this time gets updated to current time plus the lock
duration as specified during the Queue/Subscription creation.
Will return undefined until a AMQP receiver link has been successfully set up for the session.
sessionLockedUntilUtc: Date
Property Value
Date
Inherited Property Details
entityPath
Path of the entity for which the receiver has been created.
entityPath: string
Property Value
string
Inherited From ServiceBusReceiver.entityPath
identifier
A name used to identify the receiver. This can be used to correlate logs and exceptions. If not specified or empty, a random unique one will be generated.
identifier: string
Property Value
string
Inherited From ServiceBusReceiver.identifier
isClosed
Returns true
if either the receiver or the client that created it has been closed.
isClosed: boolean
Property Value
boolean
Inherited From ServiceBusReceiver.isClosed
receiveMode
The receive mode used to create the receiver.
receiveMode: "peekLock" | "receiveAndDelete"
Property Value
"peekLock" | "receiveAndDelete"
Inherited From ServiceBusReceiver.receiveMode
Method Details
getSessionState(OperationOptionsBase)
Gets the state of the Session. For more on session states, see Session State
function getSessionState(options?: OperationOptionsBase): Promise<any>
Parameters
- options
- OperationOptionsBase
Options bag to pass an abort signal or tracing options.
Returns
Promise<any>
The state of that session
renewSessionLock(OperationOptionsBase)
Renews the lock on the session.
function renewSessionLock(options?: OperationOptionsBase): Promise<Date>
Parameters
- options
- OperationOptionsBase
Returns
Promise<Date>
setSessionState(any, OperationOptionsBase)
Sets the state on the Session. For more on session states, see Session State
function setSessionState(state: any, options?: OperationOptionsBase): Promise<void>
Parameters
- state
-
any
The state that needs to be set.
- options
- OperationOptionsBase
Options bag to pass an abort signal or tracing options.
Returns
Promise<void>
subscribe(MessageHandlers, SubscribeOptions)
Streams messages to message handlers.
function subscribe(handlers: MessageHandlers, options?: SubscribeOptions): { close() => Promise<void> }
Parameters
- handlers
- MessageHandlers
A handler that gets called for messages and errors.
- options
- SubscribeOptions
Options for subscribe.
Returns
{ close() => Promise<void> }
An object that can be closed, sending any remaining messages to handlers
and
stopping new messages from arriving.
Inherited Method Details
abandonMessage(ServiceBusReceivedMessage, {[key: string]: number | boolean | string | Date | null})
The lock held on the message by the receiver is let go, making the message available again in Service Bus for another receive operation.
function abandonMessage(message: ServiceBusReceivedMessage, propertiesToModify?: {[key: string]: number | boolean | string | Date | null}): Promise<void>
Parameters
- message
- ServiceBusReceivedMessage
- propertiesToModify
-
{[key: string]: number | boolean | string | Date | null}
The properties of the message to modify while abandoning the message.
Returns
Promise<void>
Inherited From ServiceBusReceiver.abandonMessage
close()
Closes the receiver.
Once closed, the receiver cannot be used for any further operations.
Use the createReceiver()
method on the ServiceBusClient to create a new Receiver.
function close(): Promise<void>
Returns
Promise<void>
Inherited From ServiceBusReceiver.close
completeMessage(ServiceBusReceivedMessage)
Removes the message from Service Bus.
function completeMessage(message: ServiceBusReceivedMessage): Promise<void>
Parameters
- message
- ServiceBusReceivedMessage
Returns
Promise<void>
Inherited From ServiceBusReceiver.completeMessage
deadLetterMessage(ServiceBusReceivedMessage, DeadLetterOptions & {[key: string]: number | boolean | string | Date | null})
Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new QueueClient/SubscriptionClient using the path for the deadletter sub-queue.
function deadLetterMessage(message: ServiceBusReceivedMessage, options?: DeadLetterOptions & {[key: string]: number | boolean | string | Date | null}): Promise<void>
Parameters
- message
- ServiceBusReceivedMessage
- options
-
DeadLetterOptions & {[key: string]: number | boolean | string | Date | null}
The DeadLetter options that can be provided while rejecting the message.
Returns
Promise<void>
Inherited From ServiceBusReceiver.deadLetterMessage
deferMessage(ServiceBusReceivedMessage, {[key: string]: number | boolean | string | Date | null})
Defers the processing of the message. Save the sequenceNumber
of the message, in order to
receive it message again in the future using the receiveDeferredMessage
method.
function deferMessage(message: ServiceBusReceivedMessage, propertiesToModify?: {[key: string]: number | boolean | string | Date | null}): Promise<void>
Parameters
- message
- ServiceBusReceivedMessage
- propertiesToModify
-
{[key: string]: number | boolean | string | Date | null}
The properties of the message to modify while deferring the message
Returns
Promise<void>
Inherited From ServiceBusReceiver.deferMessage
getMessageIterator(GetMessageIteratorOptions)
Returns an iterator that can be used to receive messages from Service Bus.
function getMessageIterator(options?: GetMessageIteratorOptions): AsyncIterableIterator<ServiceBusReceivedMessage>
Parameters
- options
- GetMessageIteratorOptions
A set of options to control the receive operation.
abortSignal
: The signal to use to abort the ongoing operation.
Returns
AsyncIterableIterator<ServiceBusReceivedMessage>
Inherited From ServiceBusReceiver.getMessageIterator
peekMessages(number, PeekMessagesOptions)
Peek the next batch of active messages (including deferred but not deadlettered messages) on the queue or subscription without modifying them.
- The first call to
peekMessages()
fetches the first active message. Each subsequent call fetches the subsequent message. - Unlike a "received" message, "peeked" message is a read-only version of the message.
It cannot be
Completed/Abandoned/Deferred/Deadlettered
.
function peekMessages(maxMessageCount: number, options?: PeekMessagesOptions): Promise<ServiceBusReceivedMessage[]>
Parameters
- maxMessageCount
-
number
The maximum number of messages to peek.
- options
- PeekMessagesOptions
Options that allow to specify the maximum number of messages to peek, the sequenceNumber to start peeking from or an abortSignal to abort the operation.
Returns
Promise<ServiceBusReceivedMessage[]>
Inherited From ServiceBusReceiver.peekMessages
receiveDeferredMessages(Long | Long[], OperationOptionsBase)
Returns a promise that resolves to an array of deferred messages identified by given sequenceNumbers
.
function receiveDeferredMessages(sequenceNumbers: Long | Long[], options?: OperationOptionsBase): Promise<ServiceBusReceivedMessage[]>
Parameters
- sequenceNumbers
-
Long | Long[]
The sequence number or an array of sequence numbers for the messages that need to be received.
- options
- OperationOptionsBase
Options bag to pass an abort signal or tracing options.
Returns
Promise<ServiceBusReceivedMessage[]>
A list of messages identified by the given sequenceNumbers or an empty list if no messages are found.
Inherited From ServiceBusReceiver.receiveDeferredMessages
receiveMessages(number, ReceiveMessagesOptions)
Returns a promise that resolves to an array of messages received from Service Bus.
function receiveMessages(maxMessageCount: number, options?: ReceiveMessagesOptions): Promise<ServiceBusReceivedMessage[]>
Parameters
- maxMessageCount
-
number
The maximum number of messages to receive.
- options
- ReceiveMessagesOptions
A set of options to control the receive operation.
maxWaitTimeInMs
: The maximum time to wait for the first message before returning an empty array if no messages are available.abortSignal
: The signal to use to abort the ongoing operation.
Returns
Promise<ServiceBusReceivedMessage[]>
A promise that resolves with an array of messages.
Inherited From ServiceBusReceiver.receiveMessages
renewMessageLock(ServiceBusReceivedMessage)
Renews the lock on the message for the duration as specified during the Queue/Subscription creation.
- Check the
lockedUntilUtc
property on the message for the time when the lock expires. - If a message is not settled (using either
complete()
,defer()
ordeadletter()
, before its lock expires, then the message lands back in the Queue/Subscription for the next receive operation.
function renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date>
Parameters
- message
- ServiceBusReceivedMessage
Returns
Promise<Date>
New lock token expiry date and time in UTC format.
Inherited From ServiceBusReceiver.renewMessageLock