IMessageReceiver Interface

public interface IMessageReceiver extends IMessageEntityClient,IMessageBrowser

Defines message receiver interface. The MessageReceiver can be used to receive messages from Queues and Subscriptions and acknowledge them.

Method Summary

Modifier and Type Method and Description
void abandon(UUID lockToken)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

void abandon(UUID lockToken, Map<String, Object> propertiesToModify)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

void abandon(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

void abandon(UUID lockToken, TransactionContext transaction)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

CompletableFuture<Void> abandonAsync(UUID lockToken)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

CompletableFuture<Void> abandonAsync(UUID lockToken, TransactionContext transaction)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

void complete(UUID lockToken)

Completes a Message using its lock token. This will delete the message from the service.

void complete(UUID lockToken, TransactionContext transaction)

Completes a Message using its lock token. This will delete the message from the service.

CompletableFuture<Void> completeAsync(UUID lockToken)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

CompletableFuture<Void> completeAsync(UUID lockToken, TransactionContext transaction)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

void deadLetter(UUID lockToken)

Moves a Message to the deadletter sub-queue.

void deadLetter(UUID lockToken, Map<String, Object> propertiesToModify)

Moves a Message to the deadletter sub-queue with modified message properties.

void deadLetter(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with modified message properties.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

void deadLetter(UUID lockToken, TransactionContext transaction)

Moves a Message to the deadletter sub-queue.

CompletableFuture<Void> deadLetterAsync(UUID lockToken)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

void defer(UUID lockToken)

Defers a Message using its lock token. This will move message into deferred subqueue.

void defer(UUID lockToken, Map<String, Object> propertiesToModify)

Defers a Message using its lock token with modified message property. This will move message into deferred subqueue.

void defer(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Defers a Message using its lock token with modified message property. This will move message into deferred subqueue.

void defer(UUID lockToken, TransactionContext transaction)

Defers a Message using its lock token. This will move message into deferred subqueue.

CompletableFuture<Void> deferAsync(UUID lockToken)

Asynchronously defers a Message using its lock token. This will move message into deferred subqueue.

CompletableFuture<Void> deferAsync(UUID lockToken, Map<String, Object> propertiesToModify)

Asynchronously defers a Message using its lock token with modified message propert. This will move message into deferred subqueue.

CompletableFuture<Void> deferAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)

Asynchronously defers a Message using its lock token with modified message propert. This will move message into deferred subqueue.

CompletableFuture<Void> deferAsync(UUID lockToken, TransactionContext transaction)

Asynchronously defers a Message using its lock token. This will move message into deferred subqueue.

int getPrefetchCount()

Get the prefetch value set.

ReceiveMode getReceiveMode()

Get current receiver's ReceiveMode.

IMessage receive()

Receives a Message with default server wait time.

IMessage receive(Duration serverWaitTime)

Receives a Message with specified server wait time.

CompletableFuture<IMessage> receiveAsync()

Receives a Message from Azure Service Bus.

CompletableFuture<IMessage> receiveAsync(Duration serverWaitTime)

Receives a Message from Azure Service Bus with server wait time.

Collection<IMessage> receiveBatch(int maxMessageCount)

Receives a maximum of maxMessageCount Message from Azure Service Bus.

Collection<IMessage> receiveBatch(int maxMessageCount, Duration serverWaitTime)

Receives a maximum of maxMessageCount Message from Azure Service Bus with server wait time.

CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount)

Asynchronously receives a maximum of maxMessageCount Message from the entity.

CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)

Asynchronously receives a maximum of maxMessageCount Message from Azure Service Bus with server wait time.

IMessage receiveDeferredMessage(long sequenceNumber)

Receives a deferred Message. Deferred messages can only be received by using sequence number.

CompletableFuture<IMessage> receiveDeferredMessageAsync(long sequenceNumber)

Asynchronously receives a specific deferred Message identified by sequence number.

Collection<IMessage> receiveDeferredMessageBatch(Collection<Long> sequenceNumbers)

Receives a batch of deferred Message.

CompletableFuture<Collection<IMessage>> receiveDeferredMessageBatchAsync(Collection<Long> sequenceNumbers)

Asynchronously receives a set of deferred Message from the entity.

Instant renewMessageLock(IMessage message)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Instant renewMessageLock(UUID lockToken)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Note - calling this will not update getLockedUntilUtc() and updated lockedUntilUtc must be tracked by the application.

CompletableFuture<Instant> renewMessageLockAsync(IMessage message)

Asynchronously renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

CompletableFuture<Instant> renewMessageLockAsync(UUID lockToken)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Note - calling this will not update getLockedUntilUtc() and updated lockedUntilUtc must be tracked by the application.

void setPrefetchCount(int prefetchCount)

Set the prefetch count of the receiver. Prefetch speeds up the message flow by aiming to have a message readily available for local retrieval when and before the application asks for one using Receive. Setting a non-zero value prefetches PrefetchCount number of messages. Setting the value to zero turns prefetch off. For both PEEKLOCK mode and RECEIVEANDDELETE mode, the default value is 0.

The value cannot be set until the receiver is created.

Inherited Members

Method Details

abandon

public void abandon(UUID lockToken)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken - Message lock token getLockToken()

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

abandon

public void abandon(UUID lockToken, Map propertiesToModify)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

abandon

public void abandon(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

abandon

public void abandon(UUID lockToken, TransactionContext transaction)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

a CompletableFuture representing the pending abandon.

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, Map propertiesToModify)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Returns:

a CompletableFuture representing the pending abandon.

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending abandon.

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, TransactionContext transaction)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending abandon.

complete

public void complete(UUID lockToken)

Completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken - Message lock token getLockToken()

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

complete

public void complete(UUID lockToken, TransactionContext transaction)

Completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if abandon failed

completeAsync

public CompletableFuture completeAsync(UUID lockToken)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

a CompletableFuture representing the pending complete.

completeAsync

public CompletableFuture completeAsync(UUID lockToken, TransactionContext transaction)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending complete.

deadLetter

public void deadLetter(UUID lockToken)

Moves a Message to the deadletter sub-queue.

Parameters:

lockToken - Message lock token getLockToken()

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, Map propertiesToModify)

Moves a Message to the deadletter sub-queue with modified message properties.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with modified message properties.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
propertiesToModify - Message properties to modify.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetter

public void deadLetter(UUID lockToken, TransactionContext transaction)

Moves a Message to the deadletter sub-queue.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if deadletter failed

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, Map propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
propertiesToModify - Message properties to modify.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken - Message lock token getLockToken()
deadLetterReason - The deadletter reason.
deadLetterErrorDescription - The deadletter error description.
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending deadletter.

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending deadletter.

defer

public void defer(UUID lockToken)

Defers a Message using its lock token. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if defer failed

defer

public void defer(UUID lockToken, Map propertiesToModify)

Defers a Message using its lock token with modified message property. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if defer failed

defer

public void defer(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Defers a Message using its lock token with modified message property. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if defer failed

defer

public void defer(UUID lockToken, TransactionContext transaction)

Defers a Message using its lock token. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if defer failed

deferAsync

public CompletableFuture deferAsync(UUID lockToken)

Asynchronously defers a Message using its lock token. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

a CompletableFuture representing the pending defer.

deferAsync

public CompletableFuture deferAsync(UUID lockToken, Map propertiesToModify)

Asynchronously defers a Message using its lock token with modified message propert. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.

Returns:

a CompletableFuture representing the pending defer.

deferAsync

public CompletableFuture deferAsync(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Asynchronously defers a Message using its lock token with modified message propert. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
propertiesToModify - Message properties to modify.
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending defer.

deferAsync

public CompletableFuture deferAsync(UUID lockToken, TransactionContext transaction)

Asynchronously defers a Message using its lock token. This will move message into deferred subqueue.

Parameters:

lockToken - Message lock token getLockToken()
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending defer.

getPrefetchCount

public int getPrefetchCount()

Get the prefetch value set.

Returns:

The set prefetch count value.

getReceiveMode

public ReceiveMode getReceiveMode()

Get current receiver's ReceiveMode.

Returns:

receive

public IMessage receive()

Receives a Message with default server wait time.

Returns:

The received Message or null if there is no message.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receive

public IMessage receive(Duration serverWaitTime)

Receives a Message with specified server wait time.

Parameters:

serverWaitTime - The server wait time

Returns:

The received Message or null if there is no message.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receiveAsync

public CompletableFuture receiveAsync()

Receives a Message from Azure Service Bus.

Returns:

The message received. Returns null if no message is found

receiveAsync

public CompletableFuture receiveAsync(Duration serverWaitTime)

Receives a Message from Azure Service Bus with server wait time.

Parameters:

serverWaitTime - The time the client waits for receiving a message before it times out.

Returns:

The message received. Returns null if no message is found

receiveBatch

public Collection receiveBatch(int maxMessageCount)

Receives a maximum of maxMessageCount Message from Azure Service Bus.

Parameters:

maxMessageCount - The maximum number of messages that will be received.

Returns:

List of messages received. Returns null if no message is found.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receiveBatch

public Collection receiveBatch(int maxMessageCount, Duration serverWaitTime)

Receives a maximum of maxMessageCount Message from Azure Service Bus with server wait time.

Parameters:

maxMessageCount - The maximum number of messages that will be received.
serverWaitTime - The time the client waits for receiving a message before it times out.

Returns:

List of messages received. Returns null if no message is found.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receiveBatchAsync

public CompletableFuture<>> receiveBatchAsync(int maxMessageCount)

Asynchronously receives a maximum of maxMessageCount Message from the entity.

Parameters:

maxMessageCount - The maximum number of messages that will be received.

Returns:

a CompletableFuture representing the pending receive.

receiveBatchAsync

public CompletableFuture<>> receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)

Asynchronously receives a maximum of maxMessageCount Message from Azure Service Bus with server wait time.

Parameters:

maxMessageCount - The maximum number of messages that will be received.
serverWaitTime - The time the client waits for receiving a message before it times out.

Returns:

a CompletableFuture representing the pending receive.

receiveDeferredMessage

public IMessage receiveDeferredMessage(long sequenceNumber)

Receives a deferred Message. Deferred messages can only be received by using sequence number.

Parameters:

sequenceNumber - The getSequenceNumber().

Returns:

The received Message or null if there is no message for given sequence number.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receiveDeferredMessageAsync

public CompletableFuture receiveDeferredMessageAsync(long sequenceNumber)

Asynchronously receives a specific deferred Message identified by sequence number.

Parameters:

sequenceNumber - The sequence number of the message that will be received.

Returns:

a CompletableFuture representing the pending receive.

receiveDeferredMessageBatch

public Collection receiveDeferredMessageBatch(Collection sequenceNumbers)

Receives a batch of deferred Message.

Parameters:

sequenceNumbers - The sequence numbers of desired deferred messages.

Returns:

List of messages received. Returns null if no message is found.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if receive failed

receiveDeferredMessageBatchAsync

public CompletableFuture<>> receiveDeferredMessageBatchAsync(Collection sequenceNumbers)

Asynchronously receives a set of deferred Message from the entity.

Parameters:

sequenceNumbers - The sequence numbers of the message that will be received.

Returns:

a CompletableFuture representing the pending receive.

renewMessageLock

public Instant renewMessageLock(IMessage message)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Parameters:

message - The Message to be renewed

Returns:

The new locked until UTC time.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if renew failed

renewMessageLock

public Instant renewMessageLock(UUID lockToken)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Note - calling this will not update getLockedUntilUtc() and updated lockedUntilUtc must be tracked by the application.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

The new locked until UTC time.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if renew failed

renewMessageLockAsync

public CompletableFuture renewMessageLockAsync(IMessage message)

Asynchronously renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Parameters:

message - The Message to be renewed

Returns:

a CompletableFuture representing the pending renew.

renewMessageLockAsync

public CompletableFuture renewMessageLockAsync(UUID lockToken)

Renews the lock on the message specified by the lock token. The lock will be renewed based on the setting specified on the entity. When a message is received in PEEKLOCK mode, the message is locked on the server for this receiver instance for a duration as specified during the Queue/Subscription creation (LockDuration). If processing of the message requires longer than this duration, the lock needs to be renewed. For each renewal, the lock is reset to the entity's LockDuration value.

Note - calling this will not update getLockedUntilUtc() and updated lockedUntilUtc must be tracked by the application.

Parameters:

lockToken - Message lock token getLockToken()

Returns:

a CompletableFuture representing the pending renew.

setPrefetchCount

public void setPrefetchCount(int prefetchCount)

Set the prefetch count of the receiver. Prefetch speeds up the message flow by aiming to have a message readily available for local retrieval when and before the application asks for one using Receive. Setting a non-zero value prefetches PrefetchCount number of messages. Setting the value to zero turns prefetch off. For both PEEKLOCK mode and RECEIVEANDDELETE mode, the default value is 0.

The value cannot be set until the receiver is created.

Parameters:

prefetchCount - The desired prefetch count.

Throws:

ServiceBusException - if sets the value failed

Applies to