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 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 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

        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.
        Returns:
        a CompletableFuture representing the pending renew.
        See Also:
        renewSessionLock()
      • setStateAsync

        CompletableFuture<Void> 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.
        See Also:
        setState(byte[])
      • getStateAsync

        CompletableFuture<byte[]> getStateAsync()
        Asynchronously gets the session state.
        Returns:
        a CompletableFuture representing the pending session state retrieving.
        See Also:
        getState()