IMessageSession Interface
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
Modifier and Type | Method and 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 the 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. |
CompletableFuture<Void> |
renewSessionLockAsync()
Renews the lock on the session specified by the getSessionId(). The lock will be renewed based on the setting specified on the entity. |
void |
setState(byte[] state)
Set a custom state on the session which can be later retrieved using getState(). |
CompletableFuture<Void> |
setStateAsync(byte[] state)
Asynchronously set a custom state on the session which can be later retrieved using getState(). |
Inherited Members
Method Details
getLockedUntilUtc
public Instant getLockedUntilUtc()
Returns:
getSessionId
public String getSessionId()
Returns:
getState
public byte [] getState()
Gets the session state.
Returns:
Throws:
getStateAsync
public CompletableFuture
Asynchronously gets the session state.
Returns:
renewSessionLock
public void renewSessionLock()
Renews the lock on the session specified by the 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.
Throws:
renewSessionLockAsync
public CompletableFuture
Renews the lock on the session specified by the getSessionId(). The lock will be renewed based on the setting specified on the entity.
Returns:
setState
public void setState(byte[] state)
Set a custom state on the session which can be later retrieved using getState().
Parameters:
Throws:
setStateAsync
public CompletableFuture
Asynchronously set a custom state on the session which can be later retrieved using getState().
Parameters:
Returns:
Applies to
Azure SDK for Java