org.apache.activemq.artemis.spi.core.remoting

## Class SessionContext

- java.lang.Object
- - org.apache.activemq.artemis.spi.core.remoting.SessionContext

-     public abstract class SessionContext
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.activemq.artemis.utils.IDGenerator` | `idGenerator`
    `protected RemotingConnection` | `remotingConnection`
    `protected SendAcknowledgementHandler` | `sendAckHandler`
    `protected org.apache.activemq.artemis.core.client.impl.ClientSessionInternal` | `session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionContext(RemotingConnection remotingConnection)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract ClientSession.AddressQuery` | `addressQuery(SimpleString address)`
    `abstract void` | `addSessionMetadata(String key, String data)`
    `abstract void` | `addUniqueMetaData(String key, String data)`
    `abstract void` | `cleanup()`
    `abstract void` | `closeConsumer(ClientConsumer consumer)`
    `abstract boolean` | `configureTransactionTimeout(int seconds)`
    `abstract void` | `createAddress(SimpleString address, EnumSet<RoutingType> routingTypes, boolean autoCreated)`
    `abstract void` | `createAddress(SimpleString address, Set<RoutingType> routingTypes, boolean autoCreated)` Deprecated.
    `abstract org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal` | `createConsumer(SimpleString queueName, SimpleString filterString, int priority, int windowSize, int maxRate, int ackBatchSize, boolean browseOnly, Executor executor, Executor flowControlExecutor)`
    `abstract void` | `createQueue(QueueConfiguration queueConfiguration)`
    `abstract void` | `createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated)` Deprecated.
    `abstract void` | `createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated, Boolean exclusive, Boolean lastVale)`
    `abstract void` | `createQueue(SimpleString address, SimpleString queueName, boolean temp, boolean autoCreated, QueueAttributes queueAttributes)`
    `abstract void` | `createQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, boolean autoCreated)` Deprecated.
    `abstract void` | `createSharedQueue(QueueConfiguration queueConfiguration)`
    `abstract void` | `createSharedQueue(SimpleString address, SimpleString queueName, QueueAttributes queueAttributes)` Deprecated.
    `abstract void` | `createSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable)` Deprecated.
    `abstract void` | `createSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue)` Deprecated.
    `abstract void` | `createSharedQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable)` Deprecated.
    `abstract void` | `deleteQueue(SimpleString queueName)`
    `abstract void` | `expireMessage(ClientConsumer consumer, Message message)`
    `abstract void` | `forceDelivery(ClientConsumer consumer, long sequence)`
    `abstract int` | `getCreditsOnSendingFull(Message msgI)`
    `abstract int` | `getDefaultConsumerWindowSize(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionQueueQueryResponseMessage response)`
    `abstract int` | `getReconnectID()`
    `RemotingConnection` | `getRemotingConnection()`
    `abstract SendAcknowledgementHandler` | `getSendAcknowledgementHandler()`
    `abstract int` | `getServerVersion()`
    `org.apache.activemq.artemis.core.client.impl.ClientSessionInternal` | `getSession()`
    `protected void` | `handleReceiveContinuation(ConsumerContext consumerID, byte[] chunk, int flowControlSize, boolean isContinues)`
    `protected void` | `handleReceiveLargeMessage(ConsumerContext consumerID, org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal clientLargeMessage, long largeMessageSize)`
    `protected void` | `handleReceiveMessage(ConsumerContext consumerID, org.apache.activemq.artemis.core.client.impl.ClientMessageInternal message)`
    `protected void` | `handleReceiveProducerCredits(SimpleString address, int credits)`
    `protected void` | `handleReceiveProducerFailCredits(SimpleString address, int credits)`
    `abstract boolean` | `isWritable(ReadyListener callback)`
    `abstract void` | `linkFlowControl(SimpleString address, org.apache.activemq.artemis.core.client.impl.ClientProducerCredits clientProducerCredits)`
    `abstract void` | `lockCommunications()` it will lock the communication channel of the session avoiding anything to come while failover is happening.
    `abstract ClientSession.QueueQuery` | `queueQuery(SimpleString queueName)`
    `abstract boolean` | `reattachOnNewConnection(RemotingConnection newConnection)` it will either reattach or reconnect, preferably reattaching it.
    `abstract int` | `recoverSessionTimeout()` Performs a round trip to the server requesting what is the current tx timeout on the session
    `abstract void` | `recreateConsumerOnServer(org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal consumerInternal, long consumerId, boolean isSessionStarted)`
    `abstract void` | `recreateSession(String username, String password, int minLargeMessageSize, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge)`
    `abstract void` | `releaseCommunications()`
    `abstract void` | `resetMetadata(HashMap<String,String> metaDataToSend)`
    `abstract void` | `resetName(String name)`
    `abstract void` | `restartSession()`
    `abstract void` | `returnBlocking(ActiveMQException cause)` Interrupt and return any blocked calls
    `abstract void` | `sendACK(boolean individual, boolean block, ClientConsumer consumer, Message message)`
    `abstract void` | `sendConsumerCredits(ClientConsumer consumer, int credits)`
    `abstract void` | `sendFullMessage(ICoreMessage msgI, boolean sendBlocking, SendAcknowledgementHandler handler, SimpleString defaultAddress)`
    `abstract int` | `sendInitialChunkOnLargeMessage(Message msgI)` it should return the number of credits (or bytes) used to send this packet
    `abstract int` | `sendLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, int reconnectID, SendAcknowledgementHandler messageHandler)`
    `abstract void` | `sendProducerCreditsMessage(int credits, SimpleString address)`
    `abstract int` | `sendServerLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, SendAcknowledgementHandler messageHandler)`
    `abstract void` | `sessionClose()`
    `abstract void` | `sessionStart()`
    `abstract void` | `sessionStop()`
    `abstract void` | `setSendAcknowledgementHandler(SendAcknowledgementHandler handler)`
    `void` | `setSession(org.apache.activemq.artemis.core.client.impl.ClientSessionInternal session)`
    `abstract void` | `simpleCommit()`
    `abstract void` | `simpleCommit(boolean block)`
    `abstract void` | `simpleRollback(boolean lastMessageAsDelivered)` If we are doing a simple rollback on the RA, we need to ack the last message sent to the consumer, otherwise DLQ won't work.
    `abstract boolean` | `supportsLargeMessage()`
    `abstract void` | `xaCommit(Xid xid, boolean onePhase)`
    `abstract void` | `xaEnd(Xid xid, int flags)`
    `abstract void` | `xaFailed(Xid xid)`
    `abstract void` | `xaForget(Xid xid)`
    `abstract int` | `xaPrepare(Xid xid)`
    `abstract void` | `xaRollback(Xid xid, boolean wasStarted)`
    `abstract Xid[]` | `xaScan()`
    `abstract void` | `xaStart(Xid xid, int flags)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### session

          protected org.apache.activemq.artemis.core.client.impl.ClientSessionInternal session

    - #### sendAckHandler

          protected SendAcknowledgementHandler sendAckHandler

    - #### remotingConnection

          protected volatile RemotingConnection remotingConnection

    - #### idGenerator

          protected final org.apache.activemq.artemis.utils.IDGenerator idGenerator

  - ### Constructor Detail

    - #### SessionContext

          public SessionContext(RemotingConnection remotingConnection)

  - ### Method Detail

    - #### getSession

          public org.apache.activemq.artemis.core.client.impl.ClientSessionInternal getSession()

    - #### setSession

          public void setSession(org.apache.activemq.artemis.core.client.impl.ClientSessionInternal session)

    - #### resetName

          public abstract void resetName(String name)

    - #### getReconnectID

          public abstract int getReconnectID()

    - #### reattachOnNewConnection

          public abstract boolean reattachOnNewConnection(RemotingConnection newConnection)
                                                   throws ActiveMQException

      it will either reattach or reconnect, preferably reattaching it.
      Parameters:
        `newConnection` -
      Returns:
        true if it was possible to reattach
      Throws:
        `ActiveMQException`

    - #### getRemotingConnection

          public RemotingConnection getRemotingConnection()

    - #### closeConsumer

          public abstract void closeConsumer(ClientConsumer consumer)
                                      throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sendConsumerCredits

          public abstract void sendConsumerCredits(ClientConsumer consumer,
                                                   int credits)

    - #### supportsLargeMessage

          public abstract boolean supportsLargeMessage()

    - #### handleReceiveLargeMessage

          protected void handleReceiveLargeMessage(ConsumerContext consumerID,
                                                   org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal clientLargeMessage,
                                                   long largeMessageSize)
                                            throws Exception

      Throws:
        `Exception`

    - #### handleReceiveMessage

          protected void handleReceiveMessage(ConsumerContext consumerID,
                                              org.apache.activemq.artemis.core.client.impl.ClientMessageInternal message)
                                       throws Exception

      Throws:
        `Exception`

    - #### handleReceiveContinuation

          protected void handleReceiveContinuation(ConsumerContext consumerID,
                                                   byte[] chunk,
                                                   int flowControlSize,
                                                   boolean isContinues)
                                            throws Exception

      Throws:
        `Exception`

    - #### handleReceiveProducerCredits

          protected void handleReceiveProducerCredits(SimpleString address,
                                                      int credits)

    - #### handleReceiveProducerFailCredits

          protected void handleReceiveProducerFailCredits(SimpleString address,
                                                          int credits)

    - #### getCreditsOnSendingFull

          public abstract int getCreditsOnSendingFull(Message msgI)

    - #### sendFullMessage

          public abstract void sendFullMessage(ICoreMessage msgI,
                                               boolean sendBlocking,
                                               SendAcknowledgementHandler handler,
                                               SimpleString defaultAddress)
                                        throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sendInitialChunkOnLargeMessage

          public abstract int sendInitialChunkOnLargeMessage(Message msgI)
                                                      throws ActiveMQException

      it should return the number of credits (or bytes) used to send this packet
      Parameters:
        `msgI` -
      Returns:
      Throws:
        `ActiveMQException`

    - #### sendLargeMessageChunk

          public abstract int sendLargeMessageChunk(Message msgI,
                                                    long messageBodySize,
                                                    boolean sendBlocking,
                                                    boolean lastChunk,
                                                    byte[] chunk,
                                                    int reconnectID,
                                                    SendAcknowledgementHandler messageHandler)
                                             throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sendServerLargeMessageChunk

          public abstract int sendServerLargeMessageChunk(Message msgI,
                                                          long messageBodySize,
                                                          boolean sendBlocking,
                                                          boolean lastChunk,
                                                          byte[] chunk,
                                                          SendAcknowledgementHandler messageHandler)
                                                   throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### setSendAcknowledgementHandler

          public abstract void setSendAcknowledgementHandler(SendAcknowledgementHandler handler)

    - #### getSendAcknowledgementHandler

          public abstract SendAcknowledgementHandler getSendAcknowledgementHandler()

    - #### createSharedQueue

          @Deprecated
          public abstract void createSharedQueue(SimpleString address,
                                                             SimpleString queueName,
                                                             RoutingType routingType,
                                                             SimpleString filterString,
                                                             boolean durable,
                                                             Integer maxConsumers,
                                                             Boolean purgeOnNoConsumers,
                                                             Boolean exclusive,
                                                             Boolean lastValue)
                                                      throws ActiveMQException

      Deprecated.
      Creates a shared queue using the routing type set by the Address. If the Address supports more than one type of delivery then the default delivery mode (MULTICAST) is used.
      Parameters:
        `address` -
        `queueName` -
        `routingType` -
        `filterString` -
        `durable` -
        `exclusive` -
        `lastValue` -
      Throws:
        `ActiveMQException`

    - #### createSharedQueue

          @Deprecated
          public abstract void createSharedQueue(SimpleString address,
                                                             SimpleString queueName,
                                                             QueueAttributes queueAttributes)
                                                      throws ActiveMQException

      Deprecated.
      Creates a shared queue using the routing type set by the Address. If the Address supports more than one type of delivery then the default delivery mode (MULTICAST) is used.
      Parameters:
        `address` -
        `queueName` -
        `queueAttributes` -
      Throws:
        `ActiveMQException`

    - #### createSharedQueue

          @Deprecated
          public abstract void createSharedQueue(SimpleString address,
                                                             SimpleString queueName,
                                                             RoutingType routingType,
                                                             SimpleString filterString,
                                                             boolean durable)
                                                      throws ActiveMQException

      Deprecated.
      Throws:
        `ActiveMQException`

    - #### createSharedQueue

          @Deprecated
          public abstract void createSharedQueue(SimpleString address,
                                                             SimpleString queueName,
                                                             SimpleString filterString,
                                                             boolean durable)
                                                      throws ActiveMQException

      Deprecated.
      Throws:
        `ActiveMQException`

    - #### createSharedQueue

          public abstract void createSharedQueue(QueueConfiguration queueConfiguration)
                                          throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### deleteQueue

          public abstract void deleteQueue(SimpleString queueName)
                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### createAddress

          @Deprecated
          public abstract void createAddress(SimpleString address,
                                                         Set<RoutingType> routingTypes,
                                                         boolean autoCreated)
                                                  throws ActiveMQException

      Deprecated.
      Throws:
        `ActiveMQException`

    - #### createAddress

          public abstract void createAddress(SimpleString address,
                                             EnumSet<RoutingType> routingTypes,
                                             boolean autoCreated)
                                      throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### createQueue

          @Deprecated
          public abstract void createQueue(SimpleString address,
                                                       SimpleString queueName,
                                                       SimpleString filterString,
                                                       boolean durable,
                                                       boolean temp,
                                                       boolean autoCreated)
                                                throws ActiveMQException

      Deprecated.
      Throws:
        `ActiveMQException`

    - #### createQueue

          @Deprecated
          public abstract void createQueue(SimpleString address,
                                                       RoutingType routingType,
                                                       SimpleString queueName,
                                                       SimpleString filterString,
                                                       boolean durable,
                                                       boolean temp,
                                                       int maxConsumers,
                                                       boolean purgeOnNoConsumers,
                                                       boolean autoCreated)
                                                throws ActiveMQException

      Deprecated.
      Throws:
        `ActiveMQException`

    - #### createQueue

          public abstract void createQueue(SimpleString address,
                                           RoutingType routingType,
                                           SimpleString queueName,
                                           SimpleString filterString,
                                           boolean durable,
                                           boolean temp,
                                           int maxConsumers,
                                           boolean purgeOnNoConsumers,
                                           boolean autoCreated,
                                           Boolean exclusive,
                                           Boolean lastVale)
                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### createQueue

          public abstract void createQueue(SimpleString address,
                                           SimpleString queueName,
                                           boolean temp,
                                           boolean autoCreated,
                                           QueueAttributes queueAttributes)
                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### createQueue

          public abstract void createQueue(QueueConfiguration queueConfiguration)
                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### queueQuery

          public abstract ClientSession.QueueQuery queueQuery(SimpleString queueName)
                                                       throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### forceDelivery

          public abstract void forceDelivery(ClientConsumer consumer,
                                             long sequence)
                                      throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### addressQuery

          public abstract ClientSession.AddressQuery addressQuery(SimpleString address)
                                                           throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### simpleCommit

          public abstract void simpleCommit()
                                     throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### simpleCommit

          public abstract void simpleCommit(boolean block)
                                     throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### simpleRollback

          public abstract void simpleRollback(boolean lastMessageAsDelivered)
                                       throws ActiveMQException

      If we are doing a simple rollback on the RA, we need to ack the last message sent to the consumer, otherwise DLQ won't work.

      this is because we only ACK after on the RA, We may review this if we always acked earlier.

      Parameters:
        `lastMessageAsDelivered` -
      Throws:
        `ActiveMQException`

    - #### sessionStart

          public abstract void sessionStart()
                                     throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sessionStop

          public abstract void sessionStop()
                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sendACK

          public abstract void sendACK(boolean individual,
                                       boolean block,
                                       ClientConsumer consumer,
                                       Message message)
                                throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### expireMessage

          public abstract void expireMessage(ClientConsumer consumer,
                                             Message message)
                                      throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sessionClose

          public abstract void sessionClose()
                                     throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### addSessionMetadata

          public abstract void addSessionMetadata(String key,
                                                  String data)
                                           throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### addUniqueMetaData

          public abstract void addUniqueMetaData(String key,
                                                 String data)
                                          throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### sendProducerCreditsMessage

          public abstract void sendProducerCreditsMessage(int credits,
                                                          SimpleString address)

    - #### xaCommit

          public abstract void xaCommit(Xid xid,
                                        boolean onePhase)
                                 throws XAException,
                                        ActiveMQException

      Throws:
        `XAException`
        `ActiveMQException`

    - #### xaEnd

          public abstract void xaEnd(Xid xid,
                                     int flags)
                              throws XAException,
                                     ActiveMQException

      Throws:
        `XAException`
        `ActiveMQException`

    - #### xaForget

          public abstract void xaForget(Xid xid)
                                 throws XAException,
                                        ActiveMQException

      Throws:
        `XAException`
        `ActiveMQException`

    - #### xaPrepare

          public abstract int xaPrepare(Xid xid)
                                 throws XAException,
                                        ActiveMQException

      Throws:
        `XAException`
        `ActiveMQException`

    - #### xaScan

          public abstract Xid[] xaScan()
                                throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### xaRollback

          public abstract void xaRollback(Xid xid,
                                          boolean wasStarted)
                                   throws ActiveMQException,
                                          XAException

      Throws:
        `ActiveMQException`
        `XAException`

    - #### xaStart

          public abstract void xaStart(Xid xid,
                                       int flags)
                                throws XAException,
                                       ActiveMQException

      Throws:
        `XAException`
        `ActiveMQException`

    - #### configureTransactionTimeout

          public abstract boolean configureTransactionTimeout(int seconds)
                                                       throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### createConsumer

          public abstract org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal createConsumer(SimpleString queueName,
                                                                                                             SimpleString filterString,
                                                                                                             int priority,
                                                                                                             int windowSize,
                                                                                                             int maxRate,
                                                                                                             int ackBatchSize,
                                                                                                             boolean browseOnly,
                                                                                                             Executor executor,
                                                                                                             Executor flowControlExecutor)
                                                                                                      throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### recoverSessionTimeout

          public abstract int recoverSessionTimeout()
                                             throws ActiveMQException

      Performs a round trip to the server requesting what is the current tx timeout on the session
      Returns:
      Throws:
        `ActiveMQException`

    - #### getServerVersion

          public abstract int getServerVersion()

    - #### recreateSession

          public abstract void recreateSession(String username,
                                               String password,
                                               int minLargeMessageSize,
                                               boolean xa,
                                               boolean autoCommitSends,
                                               boolean autoCommitAcks,
                                               boolean preAcknowledge)
                                        throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### recreateConsumerOnServer

          public abstract void recreateConsumerOnServer(org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal consumerInternal,
                                                        long consumerId,
                                                        boolean isSessionStarted)
                                                 throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### xaFailed

          public abstract void xaFailed(Xid xid)
                                 throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### restartSession

          public abstract void restartSession()
                                       throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### resetMetadata

          public abstract void resetMetadata(HashMap<String,String> metaDataToSend)

    - #### getDefaultConsumerWindowSize

          public abstract int getDefaultConsumerWindowSize(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionQueueQueryResponseMessage response)
                                                    throws ActiveMQException

      Throws:
        `ActiveMQException`

    - #### returnBlocking

          public abstract void returnBlocking(ActiveMQException cause)

      Interrupt and return any blocked calls

    - #### lockCommunications

          public abstract void lockCommunications()

      it will lock the communication channel of the session avoiding anything to come while failover is happening. It happens on preFailover from ClientSessionImpl

    - #### releaseCommunications

          public abstract void releaseCommunications()

    - #### cleanup

          public abstract void cleanup()

    - #### linkFlowControl

          public abstract void linkFlowControl(SimpleString address,
                                               org.apache.activemq.artemis.core.client.impl.ClientProducerCredits clientProducerCredits)

    - #### isWritable

          public abstract boolean isWritable(ReadyListener callback)

Copyright © 2020 The Apache Software Foundation. All rights reserved.