MessageSession Class

  • java.lang.Object
    • ClientEntity
      • com.microsoft.azure.servicebus.InitializableEntity
        • com.microsoft.azure.servicebus.MessageReceiver
          • com.microsoft.azure.servicebus.MessageSession

public class MessageSession implements IMessageSession

Method Summary

Modifier and Type Method and Description
Instant getLockedUntilUtc()
String getRequestedSessionId()
String getSessionId()
byte [] getState()

Gets the session state.

CompletableFuture<byte[]> getStateAsync()

Asynchronously gets the session state.

boolean isBrowsableSession()
final boolean isSessionReceiver()
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[] sessionState)

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

CompletableFuture<Void> setStateAsync(byte[] sessionState)

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

Inherited Members

com.microsoft.azure.servicebus.MessageReceiver.abandon(UUID) com.microsoft.azure.servicebus.MessageReceiver.abandon(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.abandon(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.abandon(UUID,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.abandonAsync(UUID) com.microsoft.azure.servicebus.MessageReceiver.abandonAsync(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.abandonAsync(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.abandonAsync(UUID,Map<String, Object>,TransactionContext) ClientEntity.ClientEntity(final String clientId) ClientEntity.close() ICloseable.close() ClientEntity.closeAsync() ICloseable.closeAsync() com.microsoft.azure.servicebus.MessageReceiver.complete(UUID) com.microsoft.azure.servicebus.MessageReceiver.complete(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.completeAsync(UUID) com.microsoft.azure.servicebus.MessageReceiver.completeAsync(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,String,String) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,String,String,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,String,String,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.deadLetter(UUID,String,String,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,String,String) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,String,String,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,String,String,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.deadLetterAsync(UUID,String,String,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.defer(UUID) com.microsoft.azure.servicebus.MessageReceiver.defer(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.defer(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.defer(UUID,Map<String, Object>,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deferAsync(UUID) com.microsoft.azure.servicebus.MessageReceiver.deferAsync(UUID,TransactionContext) com.microsoft.azure.servicebus.MessageReceiver.deferAsync(UUID,Map<String, Object>) com.microsoft.azure.servicebus.MessageReceiver.deferAsync(UUID,Map<String, Object>,TransactionContext) ClientEntity.finalize() ClientEntity.getClientId() com.microsoft.azure.servicebus.MessageReceiver.getEntityPath() com.microsoft.azure.servicebus.MessageReceiver.getInternalReceiver() ClientEntity.getIsClosed() ClientEntity.getIsClosingOrClosed() com.microsoft.azure.servicebus.MessageReceiver.getPrefetchCount() com.microsoft.azure.servicebus.MessageReceiver.getReceiveMode() com.microsoft.azure.servicebus.InitializableEntity.InitializableEntity(String) com.microsoft.azure.servicebus.MessageReceiver.onClose() com.microsoft.azure.servicebus.MessageReceiver.peek() com.microsoft.azure.servicebus.MessageReceiver.peek(long) com.microsoft.azure.servicebus.MessageReceiver.peekAsync() com.microsoft.azure.servicebus.MessageReceiver.peekAsync(long) com.microsoft.azure.servicebus.MessageReceiver.peekBatch(int) com.microsoft.azure.servicebus.MessageReceiver.peekBatch(long,int) com.microsoft.azure.servicebus.MessageReceiver.peekBatchAsync(int) com.microsoft.azure.servicebus.MessageReceiver.peekBatchAsync(long,int) com.microsoft.azure.servicebus.MessageReceiver.receive() com.microsoft.azure.servicebus.MessageReceiver.receive(Duration) com.microsoft.azure.servicebus.MessageReceiver.receiveAsync() com.microsoft.azure.servicebus.MessageReceiver.receiveAsync(Duration) com.microsoft.azure.servicebus.MessageReceiver.receiveBatch(int) com.microsoft.azure.servicebus.MessageReceiver.receiveBatch(int,Duration) com.microsoft.azure.servicebus.MessageReceiver.receiveBatchAsync(int) com.microsoft.azure.servicebus.MessageReceiver.receiveBatchAsync(int,Duration) com.microsoft.azure.servicebus.MessageReceiver.receiveDeferredMessage(long) com.microsoft.azure.servicebus.MessageReceiver.receiveDeferredMessageAsync(long) com.microsoft.azure.servicebus.MessageReceiver.receiveDeferredMessageBatch(Collection<Long>) com.microsoft.azure.servicebus.MessageReceiver.receiveDeferredMessageBatchAsync(Collection<Long>) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLock(IMessage) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLock(UUID) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLockAsync(IMessage) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLockAsync(UUID) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLockBatch(Collection<? extends IMessage>) com.microsoft.azure.servicebus.MessageReceiver.renewMessageLockBatchAsync(Collection<? extends IMessage>) ClientEntity.setClosed() com.microsoft.azure.servicebus.MessageReceiver.setPrefetchCount(int) ClientEntity.throwIfClosed(Throwable cause)

Method Details

getLockedUntilUtc

public Instant getLockedUntilUtc()

Overrides:

MessageSession.getLockedUntilUtc()

Returns:

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

getRequestedSessionId

protected String getRequestedSessionId()

getSessionId

public String getSessionId()

Overrides:

MessageSession.getSessionId()

Returns:

Gets the SessionId.

getState

public byte [] getState()

Gets the session state.

Overrides:

MessageSession.getState()

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.

Overrides:

MessageSession.getStateAsync()

Returns:

a CompletableFuture representing the pending session state retrieving.

isBrowsableSession

protected boolean isBrowsableSession()

isSessionReceiver

protected final boolean isSessionReceiver()

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.

Overrides:

MessageSession.renewSessionLock()

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.

Overrides:

MessageSession.renewSessionLockAsync()

Returns:

a CompletableFuture representing the pending renew.

setState

public void setState(byte[] sessionState)

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

Overrides:

MessageSession.setState(byte[] sessionState)

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[] sessionState)

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

Overrides:

MessageSession.setStateAsync(byte[] sessionState)

Parameters:

state - The session state.

Returns:

a CompletableFuture representing the pending session state setting.

Applies to