Package com.microsoft.azure.servicebus
Class MessageSession
- java.lang.Object
-
- com.microsoft.azure.servicebus.primitives.ClientEntity
-
- com.microsoft.azure.servicebus.MessageSession
-
- All Implemented Interfaces:
ICloseable,IMessageBrowser,IMessageEntityClient,IMessageReceiver,IMessageSession
public class MessageSession extends ClientEntity implements IMessageSession
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabandon(UUID lockToken)AbandonMessagewith lock token.voidabandon(UUID lockToken, TransactionContext transaction)AbandonMessagewith lock token.voidabandon(UUID lockToken, Map<String,Object> propertiesToModify)AbandonMessagewith lock token and updated message property.voidabandon(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)AbandonMessagewith lock token and updated message property.CompletableFuture<Void>abandonAsync(UUID lockToken)Asynchronously abandonMessagewith lock token.CompletableFuture<Void>abandonAsync(UUID lockToken, TransactionContext transaction)Asynchronously abandonMessagewith lock token.CompletableFuture<Void>abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify)Asynchronously abandonMessagewith lock token and updated message property.CompletableFuture<Void>abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)Asynchronously abandonMessagewith lock token and updated message property.voidcomplete(UUID lockToken)Completes aMessageusing its lock token.voidcomplete(UUID lockToken, TransactionContext transaction)Completes aMessageusing its lock token.CompletableFuture<Void>completeAsync(UUID lockToken)Asynchronously completes aMessageusing its lock token.CompletableFuture<Void>completeAsync(UUID lockToken, TransactionContext transaction)Asynchronously completes aMessageusing its lock token.voiddeadLetter(UUID lockToken)Moves aMessageto the deadletter sub-queue.voiddeadLetter(UUID lockToken, TransactionContext transaction)Moves aMessageto the deadletter sub-queue.voiddeadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)Moves aMessageto the deadletter sub-queue with deadletter reason and error description.voiddeadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)Moves aMessageto the deadletter sub-queue with deadletter reason and error description.voiddeadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)Moves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.voiddeadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction)Moves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.voiddeadLetter(UUID lockToken, Map<String,Object> propertiesToModify)Moves aMessageto the deadletter sub-queue with modified message properties.voiddeadLetter(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)Moves aMessageto the deadletter sub-queue with modified message properties.CompletableFuture<Void>deadLetterAsync(UUID lockToken)Asynchronously moves aMessageto the deadletter sub-queue with deadletter.CompletableFuture<Void>deadLetterAsync(UUID lockToken, TransactionContext transaction)Asynchronously moves aMessageto the deadletter sub-queue with deadletter.CompletableFuture<Void>deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)Asynchronously moves aMessageto the deadletter sub-queue with deadletter reason and error description.CompletableFuture<Void>deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)Asynchronously moves aMessageto 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 aMessageto 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 aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.CompletableFuture<Void>deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify)Asynchronously moves aMessageto the deadletter sub-queue with modified properties.CompletableFuture<Void>deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)Asynchronously moves aMessageto the deadletter sub-queue with modified properties.voiddefer(UUID lockToken)Defers aMessageusing its lock token.voiddefer(UUID lockToken, TransactionContext transaction)Defers aMessageusing its lock token.voiddefer(UUID lockToken, Map<String,Object> propertiesToModify)Defers aMessageusing its lock token with modified message property.voiddefer(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)Defers aMessageusing its lock token with modified message property.CompletableFuture<Void>deferAsync(UUID lockToken)Asynchronously defers aMessageusing its lock token.CompletableFuture<Void>deferAsync(UUID lockToken, TransactionContext transaction)Asynchronously defers aMessageusing its lock token.CompletableFuture<Void>deferAsync(UUID lockToken, Map<String,Object> propertiesToModify)Asynchronously defers aMessageusing its lock token with modified message propert.CompletableFuture<Void>deferAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)Asynchronously defers aMessageusing its lock token with modified message propert.StringgetEntityPath()Gets the path of the entity this client is sending messages to or receiving messages from.protected CoreMessageReceivergetInternalReceiver()InstantgetLockedUntilUtc()intgetPrefetchCount()Get the prefetch value set.ReceiveModegetReceiveMode()Get current receiver'sReceiveMode.protected StringgetRequestedSessionId()StringgetSessionId()byte[]getState()Gets the session state.CompletableFuture<byte[]>getStateAsync()Asynchronously gets the session state.protected booleanisBrowsableSession()protected booleanisSessionReceiver()protected CompletableFuture<Void>onClose()IMessagepeek()reads next the active message without changing the state of the receiver or the message source.IMessagepeek(long fromSequenceNumber)Reads next the active message without changing the state of the receiver or the message source.CompletableFuture<IMessage>peekAsync()Asynchronously reads the active messages without changing the state of the receiver or the message source.CompletableFuture<IMessage>peekAsync(long fromSequenceNumber)Asynchronously reads next the active message without changing the state of the receiver or the message source.Collection<IMessage>peekBatch(int messageCount)Reads next batch of the active messages without changing the state of the receiver or the message source.Collection<IMessage>peekBatch(long fromSequenceNumber, int messageCount)Reads next batch of the active messages without changing the state of the receiver or the message source.CompletableFuture<Collection<IMessage>>peekBatchAsync(int messageCount)Asynchronously reads the next batch of active messages without changing the state of the receiver or the message source.CompletableFuture<Collection<IMessage>>peekBatchAsync(long fromSequenceNumber, int messageCount)Asynchronously reads the next batch of active messages without changing the state of the receiver or the message source.IMessagereceive()Receives aMessagewith default server wait time.IMessagereceive(Duration serverWaitTime)Receives aMessagewith specified server wait time.CompletableFuture<IMessage>receiveAsync()Receives aMessagefrom Azure Service Bus.CompletableFuture<IMessage>receiveAsync(Duration serverWaitTime)Receives aMessagefrom Azure Service Bus with server wait time.Collection<IMessage>receiveBatch(int maxMessageCount)Receives a maximum of maxMessageCountMessagefrom Azure Service Bus.Collection<IMessage>receiveBatch(int maxMessageCount, Duration serverWaitTime)Receives a maximum of maxMessageCountMessagefrom Azure Service Bus with server wait time.CompletableFuture<Collection<IMessage>>receiveBatchAsync(int maxMessageCount)Asynchronously receives a maximum of maxMessageCountMessagefrom the entity.CompletableFuture<Collection<IMessage>>receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)Asynchronously receives a maximum of maxMessageCountMessagefrom Azure Service Bus with server wait time.IMessagereceiveDeferredMessage(long sequenceNumber)Receives a deferredMessage.CompletableFuture<IMessage>receiveDeferredMessageAsync(long sequenceNumber)Asynchronously receives a specific deferredMessageidentified 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 deferredMessagefrom the entity.InstantrenewMessageLock(IMessage message)Renews the lock on the message specified by the lock token.InstantrenewMessageLock(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.Collection<Instant>renewMessageLockBatch(Collection<? extends IMessage> messages)CompletableFuture<Collection<Instant>>renewMessageLockBatchAsync(Collection<? extends IMessage> messages)voidrenewSessionLock()Renews the lock on the session specified by theIMessageSession.getSessionId().CompletableFuture<Void>renewSessionLockAsync()Renews the lock on the session specified by theIMessageSession.getSessionId().voidsetPrefetchCount(int prefetchCount)Set the prefetch count of the receiver.voidsetState(byte[] sessionState)Set a custom state on the session which can be later retrieved usingIMessageSession.getState().CompletableFuture<Void>setStateAsync(byte[] sessionState)Asynchronously set a custom state on the session which can be later retrieved usingIMessageSession.getState().-
Methods inherited from class com.microsoft.azure.servicebus.primitives.ClientEntity
close, closeAsync, finalize, getClientId, getIsClosed, getIsClosingOrClosed, setClosed, setClosing, throwIfClosed
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
Methods inherited from interface com.microsoft.azure.servicebus.IMessageReceiver
abandon, abandon, abandon, abandon, abandonAsync, abandonAsync, abandonAsync, abandonAsync, complete, complete, completeAsync, completeAsync, deadLetter, deadLetter, deadLetter, deadLetter, deadLetter, deadLetter, deadLetter, deadLetter, deadLetterAsync, deadLetterAsync, deadLetterAsync, deadLetterAsync, deadLetterAsync, deadLetterAsync, deadLetterAsync, deadLetterAsync, defer, defer, defer, defer, deferAsync, deferAsync, deferAsync, deferAsync, getPrefetchCount, getReceiveMode, receive, receive, receiveAsync, receiveAsync, receiveBatch, receiveBatch, receiveBatchAsync, receiveBatchAsync, receiveDeferredMessage, receiveDeferredMessageAsync, receiveDeferredMessageBatch, receiveDeferredMessageBatchAsync, renewMessageLock, renewMessageLock, renewMessageLockAsync, renewMessageLockAsync, setPrefetchCount
-
-
-
-
Method Detail
-
isSessionReceiver
protected final boolean isSessionReceiver()
-
isBrowsableSession
protected boolean isBrowsableSession()
-
getRequestedSessionId
protected String getRequestedSessionId()
-
getLockedUntilUtc
public Instant getLockedUntilUtc()
- Specified by:
getLockedUntilUtcin interfaceIMessageSession- Returns:
- Gets the time that the session identified by
IMessageSession.getSessionId()is locked until for this client.
-
renewSessionLock
public void renewSessionLock() throws InterruptedException, ServiceBusExceptionDescription copied from interface:IMessageSessionRenews the lock on the session specified by theIMessageSession.getSessionId(). The lock will be renewed based on the setting specified on the entity.When you accept a session, the session is locked for this client instance by the service for a duration as specified during the Queue/Subscription creation. If processing of the session requires longer than this duration, the session-lock needs to be renewed. For each renewal, the session-lock is renewed by the entity's LockDuration.
Renewal of session renews all the messages in the session as well. Each individual message need not be renewed.
- Specified by:
renewSessionLockin interfaceIMessageSession- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if the renew failed.
-
renewSessionLockAsync
public CompletableFuture<Void> renewSessionLockAsync()
Description copied from interface:IMessageSessionRenews the lock on the session specified by theIMessageSession.getSessionId(). The lock will be renewed based on the setting specified on the entity.- Specified by:
renewSessionLockAsyncin interfaceIMessageSession- Returns:
- a CompletableFuture representing the pending renew.
- See Also:
IMessageSession.renewSessionLock()
-
setState
public void setState(byte[] sessionState) throws InterruptedException, ServiceBusExceptionDescription copied from interface:IMessageSessionSet a custom state on the session which can be later retrieved usingIMessageSession.getState().- Specified by:
setStatein interfaceIMessageSession- Parameters:
sessionState- The session state.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if the set state failed.
-
setStateAsync
public CompletableFuture<Void> setStateAsync(byte[] sessionState)
Description copied from interface:IMessageSessionAsynchronously set a custom state on the session which can be later retrieved usingIMessageSession.getState().- Specified by:
setStateAsyncin interfaceIMessageSession- Parameters:
sessionState- The session state.- Returns:
- a CompletableFuture representing the pending session state setting.
- See Also:
IMessageSession.setState(byte[])
-
getState
public byte[] getState() throws InterruptedException, ServiceBusExceptionDescription copied from interface:IMessageSessionGets the session state.- Specified by:
getStatein interfaceIMessageSession- Returns:
- The session state
- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if get state failed.
-
getStateAsync
public CompletableFuture<byte[]> getStateAsync()
Description copied from interface:IMessageSessionAsynchronously gets the session state.- Specified by:
getStateAsyncin interfaceIMessageSession- Returns:
- a CompletableFuture representing the pending session state retrieving.
- See Also:
IMessageSession.getState()
-
getSessionId
public String getSessionId()
- Specified by:
getSessionIdin interfaceIMessageSession- Returns:
- Gets the SessionId.
-
getInternalReceiver
protected final CoreMessageReceiver getInternalReceiver()
-
getEntityPath
public String getEntityPath()
Description copied from interface:IMessageEntityClientGets the path of the entity this client is sending messages to or receiving messages from.- Specified by:
getEntityPathin interfaceIMessageEntityClient- Returns:
- path of the entity this client is connecting to
-
getReceiveMode
public ReceiveMode getReceiveMode()
Description copied from interface:IMessageReceiverGet current receiver'sReceiveMode.- Specified by:
getReceiveModein interfaceIMessageReceiver- Returns:
ReceiveMode
-
abandon
public void abandon(UUID lockToken) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverAbandonMessagewith lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message- Specified by:
abandonin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if abandon failed
-
abandon
public void abandon(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverAbandonMessagewith lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message- Specified by:
abandonin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if abandon failed
-
abandon
public void abandon(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverAbandonMessagewith 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- Specified by:
abandonin interfaceIMessageReceiver- 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
public void abandon(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverAbandonMessagewith 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- Specified by:
abandonin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if abandon failed
-
abandonAsync
public CompletableFuture<Void> abandonAsync(UUID lockToken)
Description copied from interface:IMessageReceiverAsynchronously abandonMessagewith lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.- Specified by:
abandonAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
public CompletableFuture<Void> abandonAsync(UUID lockToken, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously abandonMessagewith lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.- Specified by:
abandonAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
public CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Description copied from interface:IMessageReceiverAsynchronously abandonMessagewith 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.- Specified by:
abandonAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.- Returns:
- a CompletableFuture representing the pending abandon.
-
abandonAsync
public CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously abandonMessagewith 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.- Specified by:
abandonAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending abandon.
-
complete
public void complete(UUID lockToken) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverCompletes aMessageusing its lock token. This will delete the message from the service.- Specified by:
completein interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if abandon failed
-
complete
public void complete(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverCompletes aMessageusing its lock token. This will delete the message from the service.- Specified by:
completein interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if abandon failed
-
completeAsync
public CompletableFuture<Void> completeAsync(UUID lockToken)
Description copied from interface:IMessageReceiverAsynchronously completes aMessageusing its lock token. This will delete the message from the service.- Specified by:
completeAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Returns:
- a CompletableFuture representing the pending complete.
-
completeAsync
public CompletableFuture<Void> completeAsync(UUID lockToken, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously completes aMessageusing its lock token. This will delete the message from the service.- Specified by:
completeAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending complete.
-
defer
public void defer(UUID lockToken) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverDefers aMessageusing its lock token. This will move message into deferred subqueue.- Specified by:
deferin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if defer failed
-
defer
public void defer(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverDefers aMessageusing its lock token. This will move message into deferred subqueue.- Specified by:
deferin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if defer failed
-
defer
public void defer(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverDefers aMessageusing its lock token with modified message property. This will move message into deferred subqueue.- Specified by:
deferin interfaceIMessageReceiver- 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
public void defer(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverDefers aMessageusing its lock token with modified message property. This will move message into deferred subqueue.- Specified by:
deferin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if defer failed
-
deferAsync
public CompletableFuture<Void> deferAsync(UUID lockToken)
Description copied from interface:IMessageReceiverAsynchronously defers aMessageusing its lock token. This will move message into deferred subqueue.- Specified by:
deferAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
public CompletableFuture<Void> deferAsync(UUID lockToken, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously defers aMessageusing its lock token. This will move message into deferred subqueue.- Specified by:
deferAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
public CompletableFuture<Void> deferAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Description copied from interface:IMessageReceiverAsynchronously defers aMessageusing its lock token with modified message propert. This will move message into deferred subqueue.- Specified by:
deferAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.- Returns:
- a CompletableFuture representing the pending defer.
-
deferAsync
public CompletableFuture<Void> deferAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously defers aMessageusing its lock token with modified message propert. This will move message into deferred subqueue.- Specified by:
deferAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending defer.
-
deadLetter
public void deadLetter(UUID lockToken) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue.- Specified by:
deadLetterin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if deadletter failed
-
deadLetter
public void deadLetter(UUID lockToken, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue.- Specified by:
deadLetterin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if deadletter failed
-
deadLetter
public void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with modified message properties.- Specified by:
deadLetterin interfaceIMessageReceiver- 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
public void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with modified message properties.- Specified by:
deadLetterin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if deadletter failed
-
deadLetter
public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with deadletter reason and error description.- Specified by:
deadLetterin interfaceIMessageReceiver- 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
public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with deadletter reason and error description.- Specified by:
deadLetterin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()deadLetterReason- The deadletter reason.deadLetterErrorDescription- The deadletter error description.transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if deadletter failed
-
deadLetter
public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.- Specified by:
deadLetterin interfaceIMessageReceiver- 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
public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverMoves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.- Specified by:
deadLetterin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()deadLetterReason- The deadletter reason.deadLetterErrorDescription- The deadletter error description.propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if deadletter failed
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with modified properties.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with modified properties.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter reason and error description.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()deadLetterReason- The deadletter reason.deadLetterErrorDescription- The deadletter error description.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter reason and error description.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()deadLetterReason- The deadletter reason.deadLetterErrorDescription- The deadletter error description.transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
deadLetterAsync
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- 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
public CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction)
Description copied from interface:IMessageReceiverAsynchronously moves aMessageto the deadletter sub-queue with deadletter reason and error description and modified properties.- Specified by:
deadLetterAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()deadLetterReason- The deadletter reason.deadLetterErrorDescription- The deadletter error description.propertiesToModify- Message properties to modify.transaction-TransactionContextwhich this operation should enlist to.- Returns:
- a CompletableFuture representing the pending deadletter.
-
receive
public IMessage receive() throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverReceives aMessagewith default server wait time.- Specified by:
receivein interfaceIMessageReceiver- Returns:
- The received
Messageor null if there is no message. - Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if receive failed
-
receive
public IMessage receive(Duration serverWaitTime) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverReceives aMessagewith specified server wait time.- Specified by:
receivein interfaceIMessageReceiver- Parameters:
serverWaitTime- The server wait time- Returns:
- The received
Messageor null if there is no message. - Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if receive failed
-
receiveDeferredMessage
public IMessage receiveDeferredMessage(long sequenceNumber) throws ServiceBusException, InterruptedException
Description copied from interface:IMessageReceiverReceives a deferredMessage. Deferred messages can only be received by using sequence number.- Specified by:
receiveDeferredMessagein interfaceIMessageReceiver- Parameters:
sequenceNumber- TheMessage.getSequenceNumber().- Returns:
- The received
Messageor null if there is no message for given sequence number. - Throws:
ServiceBusException- if receive failedInterruptedException- if the current thread was interrupted while waiting
-
receiveBatch
public Collection<IMessage> receiveBatch(int maxMessageCount) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverReceives a maximum of maxMessageCountMessagefrom Azure Service Bus.- Specified by:
receiveBatchin interfaceIMessageReceiver- 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
public Collection<IMessage> receiveBatch(int maxMessageCount, Duration serverWaitTime) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverReceives a maximum of maxMessageCountMessagefrom Azure Service Bus with server wait time.- Specified by:
receiveBatchin interfaceIMessageReceiver- 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
public Collection<IMessage> receiveDeferredMessageBatch(Collection<Long> sequenceNumbers) throws ServiceBusException, InterruptedException
Description copied from interface:IMessageReceiverReceives a batch of deferredMessage.- Specified by:
receiveDeferredMessageBatchin interfaceIMessageReceiver- Parameters:
sequenceNumbers- The sequence numbers of desired deferred messages.- Returns:
- List of messages received. Returns null if no message is found.
- Throws:
ServiceBusException- if receive failedInterruptedException- if the current thread was interrupted while waiting
-
receiveAsync
public CompletableFuture<IMessage> receiveAsync()
Description copied from interface:IMessageReceiverReceives aMessagefrom Azure Service Bus.- Specified by:
receiveAsyncin interfaceIMessageReceiver- Returns:
- The message received. Returns null if no message is found
-
receiveAsync
public CompletableFuture<IMessage> receiveAsync(Duration serverWaitTime)
Description copied from interface:IMessageReceiverReceives aMessagefrom Azure Service Bus with server wait time.- Specified by:
receiveAsyncin interfaceIMessageReceiver- 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
-
receiveBatchAsync
public CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount)
Description copied from interface:IMessageReceiverAsynchronously receives a maximum of maxMessageCountMessagefrom the entity.- Specified by:
receiveBatchAsyncin interfaceIMessageReceiver- Parameters:
maxMessageCount- The maximum number of messages that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
receiveBatchAsync
public CompletableFuture<Collection<IMessage>> receiveBatchAsync(int maxMessageCount, Duration serverWaitTime)
Description copied from interface:IMessageReceiverAsynchronously receives a maximum of maxMessageCountMessagefrom Azure Service Bus with server wait time.- Specified by:
receiveBatchAsyncin interfaceIMessageReceiver- 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.
-
receiveDeferredMessageAsync
public CompletableFuture<IMessage> receiveDeferredMessageAsync(long sequenceNumber)
Description copied from interface:IMessageReceiverAsynchronously receives a specific deferredMessageidentified by sequence number.- Specified by:
receiveDeferredMessageAsyncin interfaceIMessageReceiver- Parameters:
sequenceNumber- The sequence number of the message that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
receiveDeferredMessageBatchAsync
public CompletableFuture<Collection<IMessage>> receiveDeferredMessageBatchAsync(Collection<Long> sequenceNumbers)
Description copied from interface:IMessageReceiverAsynchronously receives a set of deferredMessagefrom the entity.- Specified by:
receiveDeferredMessageBatchAsyncin interfaceIMessageReceiver- Parameters:
sequenceNumbers- The sequence numbers of the message that will be received.- Returns:
- a CompletableFuture representing the pending receive.
-
onClose
protected CompletableFuture<Void> onClose()
- Specified by:
onClosein classClientEntity
-
getPrefetchCount
public int getPrefetchCount()
Description copied from interface:IMessageReceiverGet the prefetch value set.- Specified by:
getPrefetchCountin interfaceIMessageReceiver- Returns:
- The set prefetch count value.
-
setPrefetchCount
public void setPrefetchCount(int prefetchCount) throws ServiceBusExceptionDescription copied from interface:IMessageReceiverSet 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.
- Specified by:
setPrefetchCountin interfaceIMessageReceiver- Parameters:
prefetchCount- The desired prefetch count.- Throws:
ServiceBusException- if sets the value failed
-
renewMessageLockAsync
public CompletableFuture<Instant> renewMessageLockAsync(IMessage message)
Description copied from interface:IMessageReceiverAsynchronously 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.PEEKLOCKmode, 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.- Specified by:
renewMessageLockAsyncin interfaceIMessageReceiver- Parameters:
message- TheMessageto be renewed- Returns:
- a CompletableFuture representing the pending renew.
-
renewMessageLockAsync
public CompletableFuture<Instant> renewMessageLockAsync(UUID lockToken)
Description copied from interface:IMessageReceiverRenews 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.PEEKLOCKmode, 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.- Specified by:
renewMessageLockAsyncin interfaceIMessageReceiver- Parameters:
lockToken- Message lock tokenMessage.getLockToken()- Returns:
- a CompletableFuture representing the pending renew.
-
renewMessageLockBatchAsync
public CompletableFuture<Collection<Instant>> renewMessageLockBatchAsync(Collection<? extends IMessage> messages)
-
renewMessageLockBatch
public Collection<Instant> renewMessageLockBatch(Collection<? extends IMessage> messages) throws InterruptedException, ServiceBusException
-
renewMessageLock
public Instant renewMessageLock(IMessage message) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverRenews 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.PEEKLOCKmode, 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.- Specified by:
renewMessageLockin interfaceIMessageReceiver- Parameters:
message- TheMessageto be renewed- Returns:
- The new locked until UTC time.
- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if renew failed
-
renewMessageLock
public Instant renewMessageLock(UUID lockToken) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageReceiverRenews 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.PEEKLOCKmode, 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.- Specified by:
renewMessageLockin interfaceIMessageReceiver- 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
-
peek
public IMessage peek() throws InterruptedException, ServiceBusException
Description copied from interface:IMessageBrowserreads next the active message without changing the state of the receiver or the message source. The first call toIMessageBrowser.peek()fetches the first active message for this receiver. Each subsequent call fetches the subsequent message in the entity.- Specified by:
peekin interfaceIMessageBrowser- Returns:
Messagepeeked- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if peek failed
-
peek
public IMessage peek(long fromSequenceNumber) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageBrowserReads next the active message without changing the state of the receiver or the message source.- Specified by:
peekin interfaceIMessageBrowser- Parameters:
fromSequenceNumber- The sequence number from where to read the message.- Returns:
Messagepeeked- Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if peek failed
-
peekBatch
public Collection<IMessage> peekBatch(int messageCount) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageBrowserReads next batch of the active messages without changing the state of the receiver or the message source.- Specified by:
peekBatchin interfaceIMessageBrowser- Parameters:
messageCount- The number of messages.- Returns:
- Batch of
Messagepeeked - Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if peek failed
-
peekBatch
public Collection<IMessage> peekBatch(long fromSequenceNumber, int messageCount) throws InterruptedException, ServiceBusException
Description copied from interface:IMessageBrowserReads next batch of the active messages without changing the state of the receiver or the message source.- Specified by:
peekBatchin interfaceIMessageBrowser- Parameters:
fromSequenceNumber- The sequence number from where to read the message.messageCount- The number of messages.- Returns:
- Batch of
Messagepeeked - Throws:
InterruptedException- if the current thread was interrupted while waitingServiceBusException- if peek failed
-
peekAsync
public CompletableFuture<IMessage> peekAsync()
Description copied from interface:IMessageBrowserAsynchronously reads the active messages without changing the state of the receiver or the message source.- Specified by:
peekAsyncin interfaceIMessageBrowser- Returns:
Messagepeeked
-
peekAsync
public CompletableFuture<IMessage> peekAsync(long fromSequenceNumber)
Description copied from interface:IMessageBrowserAsynchronously reads next the active message without changing the state of the receiver or the message source.- Specified by:
peekAsyncin interfaceIMessageBrowser- Parameters:
fromSequenceNumber- The sequence number from where to read the message.- Returns:
- CompletableFuture that returns
Messagepeeked.
-
peekBatchAsync
public CompletableFuture<Collection<IMessage>> peekBatchAsync(int messageCount)
Description copied from interface:IMessageBrowserAsynchronously reads the next batch of active messages without changing the state of the receiver or the message source.- Specified by:
peekBatchAsyncin interfaceIMessageBrowser- Parameters:
messageCount- The number of messages.- Returns:
- CompletableFuture that returns batch of
Messagepeeked.
-
peekBatchAsync
public CompletableFuture<Collection<IMessage>> peekBatchAsync(long fromSequenceNumber, int messageCount)
Description copied from interface:IMessageBrowserAsynchronously reads the next batch of active messages without changing the state of the receiver or the message source.- Specified by:
peekBatchAsyncin interfaceIMessageBrowser- Parameters:
fromSequenceNumber- The sequence number from where to read the message.messageCount- The number of messages.- Returns:
- CompletableFuture that returns batch of
Messagepeeked.
-
-