Interface IMessageSession
-
- All Superinterfaces:
ICloseable
,IMessageBrowser
,IMessageEntityClient
,IMessageReceiver
- All Known Implementing Classes:
MessageSession
public interface IMessageSession extends IMessageReceiver
Describes a Session object. IMessageSession can be used to perform operations on sessions.Service Bus Sessions, also called 'Groups' in the AMQP 1.0 protocol, are unbounded sequences of related messages. ServiceBus guarantees ordering of messages in a session.
Any sender can create a session when submitting messages into a Topic or Queue by setting the
Message.sessionId
property on Message to some application defined unique identifier. At the AMQP 1.0 protocol level, this value maps to the group-id property.Sessions come into existence when there is at least one message with the session's SessionId in the Queue or Topic subscription. Once a Session exists, there is no defined moment or gesture for when the session expires or disappears.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Instant
getLockedUntilUtc()
String
getSessionId()
byte[]
getState()
Gets the session state.CompletableFuture<byte[]>
getStateAsync()
Asynchronously gets the session state.void
renewSessionLock()
Renews the lock on the session specified by thegetSessionId()
.CompletableFuture<Void>
renewSessionLockAsync()
Renews the lock on the session specified by thegetSessionId()
.void
setState(byte[] state)
Set a custom state on the session which can be later retrieved usinggetState()
.CompletableFuture<Void>
setStateAsync(byte[] state)
Asynchronously set a custom state on the session which can be later retrieved usinggetState()
.-
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
-
getSessionId
String getSessionId()
- Returns:
- Gets the SessionId.
-
getLockedUntilUtc
Instant getLockedUntilUtc()
- Returns:
- Gets the time that the session identified by
getSessionId()
is locked until for this client.
-
renewSessionLock
void renewSessionLock() throws InterruptedException, ServiceBusException
Renews the lock on the session specified by thegetSessionId()
. 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.
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if the renew failed.
-
renewSessionLockAsync
CompletableFuture<Void> renewSessionLockAsync()
Renews the lock on the session specified by thegetSessionId()
. The lock will be renewed based on the setting specified on the entity.- Returns:
- a CompletableFuture representing the pending renew.
- See Also:
renewSessionLock()
-
setState
void setState(byte[] state) throws InterruptedException, ServiceBusException
Set a custom state on the session which can be later retrieved usinggetState()
.- Parameters:
state
- The session state.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if the set state failed.
-
setStateAsync
CompletableFuture<Void> setStateAsync(byte[] state)
Asynchronously set a custom state on the session which can be later retrieved usinggetState()
.- Parameters:
state
- The session state.- Returns:
- a CompletableFuture representing the pending session state setting.
- See Also:
setState(byte[])
-
getState
byte[] getState() throws InterruptedException, ServiceBusException
Gets the session state.- Returns:
- The session state
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if get state failed.
-
getStateAsync
CompletableFuture<byte[]> getStateAsync()
Asynchronously gets the session state.- Returns:
- a CompletableFuture representing the pending session state retrieving.
- See Also:
getState()
-
-