Class ActiveMQSessionContext
- java.lang.Object
-
- org.apache.activemq.artemis.spi.core.remoting.SessionContext
-
- org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext
-
- Direct Known Subclasses:
HornetQClientSessionContext
public class ActiveMQSessionContext extends SessionContext
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.artemis.spi.core.remoting.SessionContext
idGenerator, remotingConnection, sendAckHandler, session
-
-
Constructor Summary
Constructors Constructor Description ActiveMQSessionContext(String name, RemotingConnection remotingConnection, Channel sessionChannel, int serverVersion, int confirmationWindow)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ClientSession.AddressQueryaddressQuery(SimpleString address)voidaddSessionMetadata(String key, String data)voidaddUniqueMetaData(String key, String data)protected intcalcWindowSize(int windowSize)voidcleanup()voidcloseConsumer(ClientConsumer consumer)booleanconfigureTransactionTimeout(int seconds)voidcreateAddress(SimpleString address, EnumSet<RoutingType> routingTypes, boolean autoCreated)voidcreateAddress(SimpleString address, Set<RoutingType> routingTypes, boolean autoCreated)ClientConsumerInternalcreateConsumer(SimpleString queueName, SimpleString filterString, int priority, int windowSize, int maxRate, int ackBatchSize, boolean browseOnly, Executor executor, Executor flowControlExecutor)voidcreateQueue(QueueConfiguration queueConfiguration)voidcreateQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated)Deprecated.voidcreateQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated, Boolean exclusive, Boolean lastValue)Deprecated.voidcreateQueue(SimpleString address, SimpleString queueName, boolean temp, boolean autoCreated, QueueAttributes queueAttributes)Deprecated.voidcreateQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, boolean autoCreated)Deprecated.voidcreateSharedQueue(QueueConfiguration queueConfiguration)voidcreateSharedQueue(SimpleString address, SimpleString queueName, QueueAttributes queueAttributes)Deprecated.voidcreateSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable)Deprecated.voidcreateSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue)Deprecated.voidcreateSharedQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable)Deprecated.voiddeleteQueue(SimpleString queueName)voidexpireMessage(ClientConsumer consumer, Message message)voidforceDelivery(ClientConsumer consumer, long sequence)protected intgetConfirmationWindow()intgetCreditsOnSendingFull(Message msgI)intgetDefaultConsumerWindowSize(SessionQueueQueryResponseMessage response)protected StringgetName()intgetReconnectID()SendAcknowledgementHandlergetSendAcknowledgementHandler()intgetServerVersion()ChannelgetSessionChannel()protected voidhandleReceiveProducerCredits(SessionProducerCreditsMessage message)protected voidhandleReceiveProducerFailCredits(SessionProducerCreditsFailMessage message)protected voidhandleReceiveSlowConsumerKillMessage(DisconnectConsumerWithKillMessage message)booleanisKilled()booleanisWritable(ReadyListener callback)voidkill()voidlinkFlowControl(SimpleString address, ClientProducerCredits clientProducerCredits)voidlockCommunications()it will lock the communication channel of the session avoiding anything to come while failover is happening.protected ClassLoaderlookupTCCL()protected CreateSessionMessagenewCreateSession(String username, String password, int minLargeMessageSize, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge)ClientSession.QueueQueryqueueQuery(SimpleString queueName)booleanreattachOnNewConnection(RemotingConnection newConnection)it will either reattach or reconnect, preferably reattaching it.intrecoverSessionTimeout()Performs a round trip to the server requesting what is the current tx timeout on the sessionvoidrecreateConsumerOnServer(ClientConsumerInternal consumerInternal, long consumerId, boolean isSessionStarted)voidrecreateSession(String username, String password, int minLargeMessageSize, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge)voidreleaseCommunications()voidresetMetadata(HashMap<String,String> metaDataToSend)voidresetName(String name)voidrestartSession()voidreturnBlocking(ActiveMQException cause)Interrupt and return any blocked callsvoidsendACK(boolean individual, boolean block, ClientConsumer consumer, Message message)voidsendConsumerCredits(ClientConsumer consumer, int credits)voidsendFullMessage(ICoreMessage msgI, boolean sendBlocking, SendAcknowledgementHandler handler, SimpleString defaultAddress)intsendInitialChunkOnLargeMessage(Message msgI)it should return the number of credits (or bytes) used to send this packetintsendLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, int reconnectID, SendAcknowledgementHandler messageHandler)voidsendProducerCreditsMessage(int credits, SimpleString address)intsendServerLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, SendAcknowledgementHandler messageHandler)voidsessionClose()voidsessionStart()voidsessionStop()voidsetSendAcknowledgementHandler(SendAcknowledgementHandler handler)voidsimpleCommit()voidsimpleCommit(boolean block)voidsimpleRollback(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.booleansupportsLargeMessage()ActiveMQ Artemis does support large messagesvoidtransferConnection(RemotingConnection newConnection)Transfers the session context to the given newConnection on the client-sidevoidxaCommit(Xid xid, boolean onePhase)voidxaEnd(Xid xid, int flags)voidxaFailed(Xid xid)voidxaForget(Xid xid)intxaPrepare(Xid xid)voidxaRollback(Xid xid, boolean wasStarted)Xid[]xaScan()voidxaStart(Xid xid, int flags)-
Methods inherited from class org.apache.activemq.artemis.spi.core.remoting.SessionContext
getRemotingConnection, getSession, handleReceiveContinuation, handleReceiveLargeMessage, handleReceiveMessage, handleReceiveProducerCredits, handleReceiveProducerFailCredits, setSession
-
-
-
-
Constructor Detail
-
ActiveMQSessionContext
public ActiveMQSessionContext(String name, RemotingConnection remotingConnection, Channel sessionChannel, int serverVersion, int confirmationWindow)
-
-
Method Detail
-
getSessionChannel
public Channel getSessionChannel()
-
getName
protected String getName()
-
resetName
public void resetName(String name)
- Specified by:
resetNamein classSessionContext
-
getConfirmationWindow
protected int getConfirmationWindow()
-
getReconnectID
public int getReconnectID()
- Specified by:
getReconnectIDin classSessionContext
-
isKilled
public boolean isKilled()
-
kill
public void kill()
-
returnBlocking
public void returnBlocking(ActiveMQException cause)
Description copied from class:SessionContextInterrupt and return any blocked calls- Specified by:
returnBlockingin classSessionContext
-
lockCommunications
public void lockCommunications()
Description copied from class:SessionContextit will lock the communication channel of the session avoiding anything to come while failover is happening. It happens on preFailover from ClientSessionImpl- Specified by:
lockCommunicationsin classSessionContext
-
releaseCommunications
public void releaseCommunications()
- Specified by:
releaseCommunicationsin classSessionContext
-
cleanup
public void cleanup()
- Specified by:
cleanupin classSessionContext
-
linkFlowControl
public void linkFlowControl(SimpleString address, ClientProducerCredits clientProducerCredits)
- Specified by:
linkFlowControlin classSessionContext
-
setSendAcknowledgementHandler
public void setSendAcknowledgementHandler(SendAcknowledgementHandler handler)
- Specified by:
setSendAcknowledgementHandlerin classSessionContext
-
getSendAcknowledgementHandler
public SendAcknowledgementHandler getSendAcknowledgementHandler()
- Specified by:
getSendAcknowledgementHandlerin classSessionContext
-
createSharedQueue
@Deprecated public void createSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue) throws ActiveMQException
Deprecated.Description copied from class:SessionContextCreates 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.- Specified by:
createSharedQueuein classSessionContext- Throws:
ActiveMQException
-
createSharedQueue
@Deprecated public void createSharedQueue(SimpleString address, SimpleString queueName, QueueAttributes queueAttributes) throws ActiveMQException
Deprecated.Description copied from class:SessionContextCreates 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.- Specified by:
createSharedQueuein classSessionContext- Throws:
ActiveMQException
-
createSharedQueue
public void createSharedQueue(QueueConfiguration queueConfiguration) throws ActiveMQException
- Specified by:
createSharedQueuein classSessionContext- Throws:
ActiveMQException
-
createSharedQueue
@Deprecated public void createSharedQueue(SimpleString address, SimpleString queueName, RoutingType routingType, SimpleString filterString, boolean durable) throws ActiveMQException
Deprecated.- Specified by:
createSharedQueuein classSessionContext- Throws:
ActiveMQException
-
createSharedQueue
@Deprecated public void createSharedQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable) throws ActiveMQException
Deprecated.- Specified by:
createSharedQueuein classSessionContext- Throws:
ActiveMQException
-
deleteQueue
public void deleteQueue(SimpleString queueName) throws ActiveMQException
- Specified by:
deleteQueuein classSessionContext- Throws:
ActiveMQException
-
queueQuery
public ClientSession.QueueQuery queueQuery(SimpleString queueName) throws ActiveMQException
- Specified by:
queueQueryin classSessionContext- Throws:
ActiveMQException
-
isWritable
public boolean isWritable(ReadyListener callback)
- Specified by:
isWritablein classSessionContext
-
createConsumer
public ClientConsumerInternal createConsumer(SimpleString queueName, SimpleString filterString, int priority, int windowSize, int maxRate, int ackBatchSize, boolean browseOnly, Executor executor, Executor flowControlExecutor) throws ActiveMQException
- Specified by:
createConsumerin classSessionContext- Throws:
ActiveMQException
-
getServerVersion
public int getServerVersion()
- Specified by:
getServerVersionin classSessionContext
-
addressQuery
public ClientSession.AddressQuery addressQuery(SimpleString address) throws ActiveMQException
- Specified by:
addressQueryin classSessionContext- Throws:
ActiveMQException
-
closeConsumer
public void closeConsumer(ClientConsumer consumer) throws ActiveMQException
- Specified by:
closeConsumerin classSessionContext- Throws:
ActiveMQException
-
sendConsumerCredits
public void sendConsumerCredits(ClientConsumer consumer, int credits)
- Specified by:
sendConsumerCreditsin classSessionContext
-
forceDelivery
public void forceDelivery(ClientConsumer consumer, long sequence) throws ActiveMQException
- Specified by:
forceDeliveryin classSessionContext- Throws:
ActiveMQException
-
simpleCommit
public void simpleCommit() throws ActiveMQException- Specified by:
simpleCommitin classSessionContext- Throws:
ActiveMQException
-
simpleCommit
public void simpleCommit(boolean block) throws ActiveMQException- Specified by:
simpleCommitin classSessionContext- Throws:
ActiveMQException
-
simpleRollback
public void simpleRollback(boolean lastMessageAsDelivered) throws ActiveMQExceptionDescription copied from class:SessionContextIf 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.
- Specified by:
simpleRollbackin classSessionContext- Throws:
ActiveMQException
-
sessionStart
public void sessionStart() throws ActiveMQException- Specified by:
sessionStartin classSessionContext- Throws:
ActiveMQException
-
sessionStop
public void sessionStop() throws ActiveMQException- Specified by:
sessionStopin classSessionContext- Throws:
ActiveMQException
-
addSessionMetadata
public void addSessionMetadata(String key, String data) throws ActiveMQException
- Specified by:
addSessionMetadatain classSessionContext- Throws:
ActiveMQException
-
addUniqueMetaData
public void addUniqueMetaData(String key, String data) throws ActiveMQException
- Specified by:
addUniqueMetaDatain classSessionContext- Throws:
ActiveMQException
-
xaCommit
public void xaCommit(Xid xid, boolean onePhase) throws XAException, ActiveMQException
- Specified by:
xaCommitin classSessionContext- Throws:
XAExceptionActiveMQException
-
xaEnd
public void xaEnd(Xid xid, int flags) throws XAException, ActiveMQException
- Specified by:
xaEndin classSessionContext- Throws:
XAExceptionActiveMQException
-
sendProducerCreditsMessage
public void sendProducerCreditsMessage(int credits, SimpleString address)- Specified by:
sendProducerCreditsMessagein classSessionContext
-
supportsLargeMessage
public boolean supportsLargeMessage()
ActiveMQ Artemis does support large messages- Specified by:
supportsLargeMessagein classSessionContext- Returns:
-
getCreditsOnSendingFull
public int getCreditsOnSendingFull(Message msgI)
- Specified by:
getCreditsOnSendingFullin classSessionContext
-
sendFullMessage
public void sendFullMessage(ICoreMessage msgI, boolean sendBlocking, SendAcknowledgementHandler handler, SimpleString defaultAddress) throws ActiveMQException
- Specified by:
sendFullMessagein classSessionContext- Throws:
ActiveMQException
-
sendInitialChunkOnLargeMessage
public int sendInitialChunkOnLargeMessage(Message msgI) throws ActiveMQException
Description copied from class:SessionContextit should return the number of credits (or bytes) used to send this packet- Specified by:
sendInitialChunkOnLargeMessagein classSessionContext- Returns:
- Throws:
ActiveMQException
-
sendLargeMessageChunk
public int sendLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, int reconnectID, SendAcknowledgementHandler messageHandler) throws ActiveMQException
- Specified by:
sendLargeMessageChunkin classSessionContext- Throws:
ActiveMQException
-
sendServerLargeMessageChunk
public int sendServerLargeMessageChunk(Message msgI, long messageBodySize, boolean sendBlocking, boolean lastChunk, byte[] chunk, SendAcknowledgementHandler messageHandler) throws ActiveMQException
- Specified by:
sendServerLargeMessageChunkin classSessionContext- Throws:
ActiveMQException
-
sendACK
public void sendACK(boolean individual, boolean block, ClientConsumer consumer, Message message) throws ActiveMQException- Specified by:
sendACKin classSessionContext- Throws:
ActiveMQException
-
expireMessage
public void expireMessage(ClientConsumer consumer, Message message) throws ActiveMQException
- Specified by:
expireMessagein classSessionContext- Throws:
ActiveMQException
-
sessionClose
public void sessionClose() throws ActiveMQException- Specified by:
sessionClosein classSessionContext- Throws:
ActiveMQException
-
xaForget
public void xaForget(Xid xid) throws XAException, ActiveMQException
- Specified by:
xaForgetin classSessionContext- Throws:
XAExceptionActiveMQException
-
xaPrepare
public int xaPrepare(Xid xid) throws XAException, ActiveMQException
- Specified by:
xaPreparein classSessionContext- Throws:
XAExceptionActiveMQException
-
xaScan
public Xid[] xaScan() throws ActiveMQException
- Specified by:
xaScanin classSessionContext- Throws:
ActiveMQException
-
xaRollback
public void xaRollback(Xid xid, boolean wasStarted) throws ActiveMQException, XAException
- Specified by:
xaRollbackin classSessionContext- Throws:
ActiveMQExceptionXAException
-
xaStart
public void xaStart(Xid xid, int flags) throws XAException, ActiveMQException
- Specified by:
xaStartin classSessionContext- Throws:
XAExceptionActiveMQException
-
configureTransactionTimeout
public boolean configureTransactionTimeout(int seconds) throws ActiveMQException- Specified by:
configureTransactionTimeoutin classSessionContext- Throws:
ActiveMQException
-
recoverSessionTimeout
public int recoverSessionTimeout() throws ActiveMQExceptionDescription copied from class:SessionContextPerforms a round trip to the server requesting what is the current tx timeout on the session- Specified by:
recoverSessionTimeoutin classSessionContext- Returns:
- Throws:
ActiveMQException
-
createAddress
public void createAddress(SimpleString address, Set<RoutingType> routingTypes, boolean autoCreated) throws ActiveMQException
- Specified by:
createAddressin classSessionContext- Throws:
ActiveMQException
-
createAddress
public void createAddress(SimpleString address, EnumSet<RoutingType> routingTypes, boolean autoCreated) throws ActiveMQException
- Specified by:
createAddressin classSessionContext- Throws:
ActiveMQException
-
createQueue
@Deprecated public void createQueue(SimpleString address, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, boolean autoCreated) throws ActiveMQException
Deprecated.- Specified by:
createQueuein classSessionContext- Throws:
ActiveMQException
-
createQueue
@Deprecated public void createQueue(SimpleString address, SimpleString queueName, boolean temp, boolean autoCreated, QueueAttributes queueAttributes) throws ActiveMQException
Deprecated.- Specified by:
createQueuein classSessionContext- Throws:
ActiveMQException
-
createQueue
@Deprecated public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated, Boolean exclusive, Boolean lastValue) throws ActiveMQException
Deprecated.- Specified by:
createQueuein classSessionContext- Throws:
ActiveMQException
-
createQueue
@Deprecated public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString, boolean durable, boolean temp, int maxConsumers, boolean purgeOnNoConsumers, boolean autoCreated) throws ActiveMQException
Deprecated.- Specified by:
createQueuein classSessionContext- Throws:
ActiveMQException
-
createQueue
public void createQueue(QueueConfiguration queueConfiguration) throws ActiveMQException
- Specified by:
createQueuein classSessionContext- Throws:
ActiveMQException
-
transferConnection
public void transferConnection(RemotingConnection newConnection)
Description copied from class:SessionContextTransfers the session context to the given newConnection on the client-side- Specified by:
transferConnectionin classSessionContext
-
reattachOnNewConnection
public boolean reattachOnNewConnection(RemotingConnection newConnection) throws ActiveMQException
Description copied from class:SessionContextit will either reattach or reconnect, preferably reattaching it.- Specified by:
reattachOnNewConnectionin classSessionContext- Returns:
- true if it was possible to reattach
- Throws:
ActiveMQException
-
recreateSession
public void recreateSession(String username, String password, int minLargeMessageSize, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException
- Specified by:
recreateSessionin classSessionContext- Throws:
ActiveMQException
-
newCreateSession
protected CreateSessionMessage newCreateSession(String username, String password, int minLargeMessageSize, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge)
-
recreateConsumerOnServer
public void recreateConsumerOnServer(ClientConsumerInternal consumerInternal, long consumerId, boolean isSessionStarted) throws ActiveMQException
- Specified by:
recreateConsumerOnServerin classSessionContext- Throws:
ActiveMQException
-
xaFailed
public void xaFailed(Xid xid) throws ActiveMQException
- Specified by:
xaFailedin classSessionContext- Throws:
ActiveMQException
-
restartSession
public void restartSession() throws ActiveMQException- Specified by:
restartSessionin classSessionContext- Throws:
ActiveMQException
-
resetMetadata
public void resetMetadata(HashMap<String,String> metaDataToSend)
- Specified by:
resetMetadatain classSessionContext
-
getDefaultConsumerWindowSize
public int getDefaultConsumerWindowSize(SessionQueueQueryResponseMessage response) throws ActiveMQException
- Specified by:
getDefaultConsumerWindowSizein classSessionContext- Throws:
ActiveMQException
-
handleReceiveProducerCredits
protected void handleReceiveProducerCredits(SessionProducerCreditsMessage message)
-
handleReceiveProducerFailCredits
protected void handleReceiveProducerFailCredits(SessionProducerCreditsFailMessage message)
-
handleReceiveSlowConsumerKillMessage
protected void handleReceiveSlowConsumerKillMessage(DisconnectConsumerWithKillMessage message)
-
lookupTCCL
protected ClassLoader lookupTCCL()
-
calcWindowSize
protected int calcWindowSize(int windowSize)
-
-