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

IMessageReceiver.abandon(UUID lockToken) IMessageReceiver.abandon(UUID lockToken, TransactionContext transaction) IMessageReceiver.abandon(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.abandon(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.abandonAsync(UUID lockToken) IMessageReceiver.abandonAsync(UUID lockToken, TransactionContext transaction) IMessageReceiver.abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) ICloseable.close() ICloseable.closeAsync() IMessageReceiver.complete(UUID lockToken) IMessageReceiver.complete(UUID lockToken, TransactionContext transaction) IMessageReceiver.completeAsync(UUID lockToken) IMessageReceiver.completeAsync(UUID lockToken, TransactionContext transaction) IMessageReceiver.deadLetter(UUID lockToken) IMessageReceiver.deadLetter(UUID lockToken, TransactionContext transaction) IMessageReceiver.deadLetter(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.deadLetter(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription) IMessageReceiver.deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction) IMessageReceiver.deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify) IMessageReceiver.deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.deadLetterAsync(UUID lockToken) IMessageReceiver.deadLetterAsync(UUID lockToken, TransactionContext transaction) IMessageReceiver.deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription) IMessageReceiver.deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction) IMessageReceiver.deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify) IMessageReceiver.deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.defer(UUID lockToken) IMessageReceiver.defer(UUID lockToken, TransactionContext transaction) IMessageReceiver.defer(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.defer(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageReceiver.deferAsync(UUID lockToken) IMessageReceiver.deferAsync(UUID lockToken, TransactionContext transaction) IMessageReceiver.deferAsync(UUID lockToken, Map<String, Object> propertiesToModify) IMessageReceiver.deferAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction) IMessageEntityClient.getEntityPath() IMessageReceiver.getPrefetchCount() IMessageReceiver.getReceiveMode() IMessageBrowser.peek() IMessageBrowser.peek(long fromSequenceNumber) IMessageBrowser.peekAsync() IMessageBrowser.peekAsync(long fromSequenceNumber) IMessageBrowser.peekBatch(int messageCount) IMessageBrowser.peekBatch(long fromSequenceNumber, int messageCount) IMessageBrowser.peekBatchAsync(int messageCount) IMessageBrowser.peekBatchAsync(long fromSequenceNumber, int messageCount) IMessageReceiver.receive() IMessageReceiver.receive(Duration serverWaitTime) IMessageReceiver.receiveAsync() IMessageReceiver.receiveAsync(Duration serverWaitTime) IMessageReceiver.receiveBatch(int maxMessageCount) IMessageReceiver.receiveBatch(int maxMessageCount, Duration serverWaitTime) IMessageReceiver.receiveBatchAsync(int maxMessageCount) IMessageReceiver.receiveBatchAsync(int maxMessageCount, Duration serverWaitTime) IMessageReceiver.receiveDeferredMessage(long sequenceNumber) IMessageReceiver.receiveDeferredMessageAsync(long sequenceNumber) IMessageReceiver.receiveDeferredMessageBatch(Collection<Long> sequenceNumbers) IMessageReceiver.receiveDeferredMessageBatchAsync(Collection<Long> sequenceNumbers) IMessageReceiver.renewMessageLock(IMessage message) IMessageReceiver.renewMessageLock(UUID lockToken) IMessageReceiver.renewMessageLockAsync(IMessage message) IMessageReceiver.renewMessageLockAsync(UUID lockToken) IMessageReceiver.setPrefetchCount(int prefetchCount)

Method Details

getLockedUntilUtc

public Instant getLockedUntilUtc()

Returns:

Gets the time that the session identified by getSessionId() is locked until for this client.

getSessionId

public String getSessionId()

Returns:

Gets the SessionId.

getState

public byte [] getState()

Gets the session state.

Returns:

The session state

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if get state failed.

getStateAsync

public CompletableFuture getStateAsync()

Asynchronously gets the session state.

Returns:

a CompletableFuture representing the pending session state retrieving.

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:

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

renewSessionLockAsync

public CompletableFuture renewSessionLockAsync()

Renews the lock on the session specified by the getSessionId(). The lock will be renewed based on the setting specified on the entity.

Returns:

a CompletableFuture representing the pending renew.

setState

public void setState(byte[] state)

Set a custom state on the session which can be later retrieved using getState().

Parameters:

state - The session state.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if the set state failed.

setStateAsync

public CompletableFuture setStateAsync(byte[] state)

Asynchronously set a custom state on the session which can be later retrieved using getState().

Parameters:

state - The session state.

Returns:

a CompletableFuture representing the pending session state setting.

Applies to