Package com.microsoft.azure.servicebus
Interface IMessageReceiver
-
- All Superinterfaces:
ICloseable
,IMessageBrowser
,IMessageEntityClient
- All Known Subinterfaces:
IMessageSession
- All Known Implementing Classes:
MessageSession
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
abandon(UUID lockToken)
AbandonMessage
with lock token.void
abandon(UUID lockToken, TransactionContext transaction)
AbandonMessage
with lock token.void
abandon(UUID lockToken, Map<String,Object> propertiesToModify)
AbandonMessage
with lock token and updated message property.void
abandon(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
AbandonMessage
with lock token and updated message property.CompletableFuture<Void>
abandonAsync(UUID lockToken)
Asynchronously abandonMessage
with lock token.CompletableFuture<Void>
abandonAsync(UUID lockToken, TransactionContext transaction)
Asynchronously abandonMessage
with lock token.CompletableFuture<Void>
abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously abandonMessage
with lock token and updated message property.CompletableFuture<Void>
abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously abandonMessage
with lock token and updated message property.void
complete(UUID lockToken)
Completes aMessage
using its lock token.void
complete(UUID lockToken, TransactionContext transaction)
Completes aMessage
using its lock token.CompletableFuture<Void>
completeAsync(UUID lockToken)
Asynchronously completes aMessage
using its lock token.CompletableFuture<Void>
completeAsync(UUID lockToken, TransactionContext transaction)
Asynchronously completes aMessage
using its lock token.void
deadLetter(UUID lockToken)
Moves aMessage
to the deadletter sub-queue.void
deadLetter(UUID lockToken, TransactionContext transaction)
Moves aMessage
to the deadletter sub-queue.void
deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description.void
deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description.void
deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)
Moves aMessage
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 aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.void
deadLetter(UUID lockToken, Map<String,Object> propertiesToModify)
Moves aMessage
to the deadletter sub-queue with modified message properties.void
deadLetter(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Moves aMessage
to the deadletter sub-queue with modified message properties.CompletableFuture<Void>
deadLetterAsync(UUID lockToken)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter.CompletableFuture<Void>
deadLetterAsync(UUID lockToken, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter.CompletableFuture<Void>
deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter reason and error description.CompletableFuture<Void>
deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
Asynchronously moves aMessage
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 aMessage
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 aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.CompletableFuture<Void>
deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously moves aMessage
to the deadletter sub-queue with modified properties.CompletableFuture<Void>
deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with modified properties.void
defer(UUID lockToken)
Defers aMessage
using its lock token.void
defer(UUID lockToken, TransactionContext transaction)
Defers aMessage
using its lock token.void
defer(UUID lockToken, Map<String,Object> propertiesToModify)
Defers aMessage
using its lock token with modified message property.void
defer(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Defers aMessage
using its lock token with modified message property.CompletableFuture<Void>
deferAsync(UUID lockToken)
Asynchronously defers aMessage
using its lock token.CompletableFuture<Void>
deferAsync(UUID lockToken, TransactionContext transaction)
Asynchronously defers aMessage
using its lock token.CompletableFuture<Void>
deferAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously defers aMessage
using its lock token with modified message propert.CompletableFuture<Void>
deferAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously defers aMessage
using its lock token with modified message propert.int
getPrefetchCount()
Get the prefetch value set.ReceiveMode
getReceiveMode()
Get current receiver'sReceiveMode
.IMessage
receive()
Receives aMessage
with default server wait time.IMessage
receive(Duration serverWaitTime)
Receives aMessage
with specified server wait time.CompletableFuture<IMessage>
receiveAsync()
Receives aMessage
from Azure Service Bus.CompletableFuture<IMessage>
receiveAsync(Duration serverWaitTime)
Receives aMessage
from Azure Service Bus with server wait time.Collection<IMessage>
receiveBatch(int maxMessageCount)
Receives a maximum of maxMessageCountMessage
from Azure Service Bus.Collection<IMessage>
receiveBatch(int maxMessageCount, Duration serverWaitTime)
Receives a maximum of maxMessageCountMessage
from Azure Service Bus with server wait time.CompletableFuture<Collection<IMessage>>
receiveBatchAsync(int maxMessageCount)
Asynchronously receives a maximum of maxMessageCountMessage
from the entity.CompletableFuture<Collection<IMessage>>
receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)
Asynchronously receives a maximum of maxMessageCountMessage
from Azure Service Bus with server wait time.IMessage
receiveDeferredMessage(long sequenceNumber)
Receives a deferredMessage
.CompletableFuture<IMessage>
receiveDeferredMessageAsync(long sequenceNumber)
Asynchronously receives a specific deferredMessage
identified by sequence number.Collection<IMessage>
receiveDeferredMessageBatch(Collection<Long> sequenceNumbers)
Receives a batch of deferredMessage
.CompletableFuture<Collection<IMessage>>
receiveDeferredMessageBatchAsync(Collection<Long> sequenceNumbers)
Asynchronously receives a set of deferredMessage
from the entity.Instant
renewMessageLock(IMessage message)
Renews the lock on the message specified by the lock token.Instant
renewMessageLock(UUID lockToken)
Renews the lock on the message specified by the lock token.CompletableFuture<Instant>
renewMessageLockAsync(IMessage message)
Asynchronously renews the lock on the message specified by the lock token.CompletableFuture<Instant>
renewMessageLockAsync(UUID lockToken)
Renews the lock on the message specified by the lock token.void
setPrefetchCount(int prefetchCount)
Set the prefetch count of the receiver.-
Methods inherited from interface com.microsoft.azure.servicebus.ICloseable
close, closeAsync
-
Methods inherited from interface com.microsoft.azure.servicebus.IMessageBrowser
peek, peek, peekAsync, peekAsync, peekBatch, peekBatch, peekBatchAsync, peekBatchAsync
-
Methods inherited from interface com.microsoft.azure.servicebus.IMessageEntityClient
getEntityPath
-
-
-
-
Method Detail
-
getReceiveMode
ReceiveMode getReceiveMode()
Get current receiver'sReceiveMode
.- Returns:
ReceiveMode
-
abandon
void abandon(UUID lockToken) throws InterruptedException, ServiceBusException
AbandonMessage
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 tokenMessage.getLockToken()
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
abandon
void abandon(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
AbandonMessage
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 tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
abandon
void abandon(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
AbandonMessage
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 tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
abandon
void abandon(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
AbandonMessage
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 tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
abandonAsync
CompletableFuture<Void> abandonAsync(UUID lockToken)
Asynchronously abandonMessage
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 tokenMessage.getLockToken()
- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
CompletableFuture<Void> abandonAsync(UUID lockToken, TransactionContext transaction)
Asynchronously abandonMessage
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 tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously abandonMessage
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 tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously abandonMessage
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 tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending abandon.
-
complete
void complete(UUID lockToken) throws InterruptedException, ServiceBusException
Completes aMessage
using its lock token. This will delete the message from the service.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
complete
void complete(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Completes aMessage
using its lock token. This will delete the message from the service.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if abandon failed
-
completeAsync
CompletableFuture<Void> completeAsync(UUID lockToken)
Asynchronously completes aMessage
using its lock token. This will delete the message from the service.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Returns:
- a CompletableFuture representing the pending complete.
-
completeAsync
CompletableFuture<Void> completeAsync(UUID lockToken, TransactionContext transaction)
Asynchronously completes aMessage
using its lock token. This will delete the message from the service.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending complete.
-
defer
void defer(UUID lockToken) throws InterruptedException, ServiceBusException
Defers aMessage
using its lock token. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if defer failed
-
defer
void defer(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Defers aMessage
using its lock token. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if defer failed
-
defer
void defer(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Defers aMessage
using its lock token with modified message property. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if defer failed
-
defer
void defer(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Defers aMessage
using its lock token with modified message property. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if defer failed
-
deferAsync
CompletableFuture<Void> deferAsync(UUID lockToken)
Asynchronously defers aMessage
using its lock token. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
CompletableFuture<Void> deferAsync(UUID lockToken, TransactionContext transaction)
Asynchronously defers aMessage
using its lock token. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
CompletableFuture<Void> deferAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously defers aMessage
using its lock token with modified message propert. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
CompletableFuture<Void> deferAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously defers aMessage
using its lock token with modified message propert. This will move message into deferred subqueue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending defer.
-
deadLetter
void deadLetter(UUID lockToken) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with modified message properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with modified message properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
deadLetterReason
- The deadletter reason.deadLetterErrorDescription
- The deadletter error description.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description.- Parameters:
lockToken
- Message lock tokenMessage.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 waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
deadLetterReason
- The deadletter reason.deadLetterErrorDescription
- The deadletter error description.propertiesToModify
- Message properties to modify.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if deadletter failed
-
deadLetter
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Moves aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.- Parameters:
lockToken
- Message lock tokenMessage.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 waitingServiceBusException
- if deadletter failed
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Asynchronously moves aMessage
to the deadletter sub-queue with modified properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with modified properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
propertiesToModify
- Message properties to modify.transaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter reason and error description.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
deadLetterReason
- The deadletter reason.deadLetterErrorDescription
- The deadletter error description.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter reason and error description.- Parameters:
lockToken
- Message lock tokenMessage.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
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
deadLetterReason
- The deadletter reason.deadLetterErrorDescription
- The deadletter error description.propertiesToModify
- Message properties to modify.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction)
Asynchronously moves aMessage
to the deadletter sub-queue with deadletter reason and error description and modified properties.- Parameters:
lockToken
- Message lock tokenMessage.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.
-
receive
IMessage receive() throws InterruptedException, ServiceBusException
Receives aMessage
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 waitingServiceBusException
- if receive failed
-
receive
IMessage receive(Duration serverWaitTime) throws InterruptedException, ServiceBusException
Receives aMessage
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 waitingServiceBusException
- if receive failed
-
receiveDeferredMessage
IMessage receiveDeferredMessage(long sequenceNumber) throws InterruptedException, ServiceBusException
Receives a deferredMessage
. Deferred messages can only be received by using sequence number.- Parameters:
sequenceNumber
- TheMessage.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 waitingServiceBusException
- if receive failed
-
receiveBatch
Collection<IMessage> receiveBatch(int maxMessageCount) throws InterruptedException, ServiceBusException
Receives a maximum of maxMessageCountMessage
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 waitingServiceBusException
- if receive failed
-
receiveBatch
Collection<IMessage> receiveBatch(int maxMessageCount, Duration serverWaitTime) throws InterruptedException, ServiceBusException
Receives a maximum of maxMessageCountMessage
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 waitingServiceBusException
- if receive failed
-
receiveDeferredMessageBatch
Collection<IMessage> receiveDeferredMessageBatch(Collection<Long> sequenceNumbers) throws InterruptedException, ServiceBusException
Receives a batch of deferredMessage
.- 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 waitingServiceBusException
- if receive failed
-
receiveAsync
CompletableFuture<IMessage> receiveAsync()
Receives aMessage
from Azure Service Bus.- Returns:
- The message received. Returns null if no message is found
-
receiveAsync
CompletableFuture<IMessage> receiveAsync(Duration serverWaitTime)
Receives aMessage
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
-
receiveDeferredMessageAsync
CompletableFuture<IMessage> receiveDeferredMessageAsync(long sequenceNumber)
Asynchronously receives a specific deferredMessage
identified by sequence number.- Parameters:
sequenceNumber
- The sequence number of the message that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
receiveBatchAsync
CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount)
Asynchronously receives a maximum of maxMessageCountMessage
from the entity.- Parameters:
maxMessageCount
- The maximum number of messages that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
receiveBatchAsync
CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)
Asynchronously receives a maximum of maxMessageCountMessage
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.
-
receiveDeferredMessageBatchAsync
CompletableFuture<Collection<IMessage>> receiveDeferredMessageBatchAsync(Collection<Long> sequenceNumbers)
Asynchronously receives a set of deferredMessage
from the entity.- Parameters:
sequenceNumbers
- The sequence numbers of the message that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
renewMessageLockAsync
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 inReceiveMode.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
- TheMessage
to be renewed- Returns:
- a CompletableFuture representing the pending renew.
-
renewMessageLockAsync
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 inReceiveMode.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 updateMessage.getLockedUntilUtc()
and updated lockedUntilUtc must be tracked by the application.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Returns:
- a CompletableFuture representing the pending renew.
-
renewMessageLock
Instant renewMessageLock(IMessage message) throws InterruptedException, ServiceBusException
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 inReceiveMode.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
- TheMessage
to be renewed- Returns:
- The new locked until UTC time.
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if renew failed
-
renewMessageLock
Instant renewMessageLock(UUID lockToken) throws InterruptedException, ServiceBusException
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 inReceiveMode.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 updateMessage.getLockedUntilUtc()
and updated lockedUntilUtc must be tracked by the application.- Parameters:
lockToken
- Message lock tokenMessage.getLockToken()
- Returns:
- The new locked until UTC time.
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if renew failed
-
getPrefetchCount
int getPrefetchCount()
Get the prefetch value set.- Returns:
- The set prefetch count value.
-
setPrefetchCount
void setPrefetchCount(int prefetchCount) throws ServiceBusException
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
-
-