Class ClientSession
java.lang.Object
org.apache.qpid.protonj2.client.impl.ClientSession
- All Implemented Interfaces:
- AutoCloseable,- Session
- Direct Known Subclasses:
- ClientStreamSession
Client implementation of the Session API.
- 
Method SummaryModifier and TypeMethodDescriptionOpens a new transaction scoped to thisSessionif one is not already active.protected voidclient()voidclose()Requests a close of theSessionat the remote and waits until the Session has been fully closed or until the configuredSessionOptions.closeTimeout()is exceeded.voidclose(ErrorCondition error) Requests a close of theSessionat the remote and waits until the Session has been fully closed or until the configuredSessionOptions.closeTimeout()is exceeded.closeAsync(ErrorCondition error) Commit the currently active transaction in this Session.String[]Returns the desired capabilities that the remote provided upon successfully opening theSession.Waits indefinitely for a receiver created from this session to have a delivery ready for receipt.nextReceiver(long timeout, TimeUnit unit) Waits for the given duration for a receiver created from this session to have a delivery ready for receipt.nextReceiver(NextReceiverPolicy policy) Waits indefinitely for a receiver created from this session to have a delivery ready for receipt.nextReceiver(NextReceiverPolicy policy, long timeout, TimeUnit unit) Waits for the given duration for a receiver created from this session to have a delivery ready for receipt.String[]Returns the offered capabilities that the remote provided upon successfully opening theSession.Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.openAnonymousSender(SenderOptions senderOptions) Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.openDurableReceiver(String address, String subscriptionName) Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.openDurableReceiver(String address, String subscriptionName, ReceiverOptions receiverOptions) Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.Creates a dynamic receiver used to consume messages from the given node address.openDynamicReceiver(Map<String, Object> dynamicNodeProperties) Creates a dynamic receiver used to consume messages from the given node address.openDynamicReceiver(Map<String, Object> dynamicNodeProperties, ReceiverOptions receiverOptions) Creates a dynamic receiver used to consume messages from the given node address.openDynamicReceiver(ReceiverOptions receiverOptions) Creates a dynamic receiver used to consume messages from the given node address.openReceiver(String address) Creates a receiver used to consume messages from the given node address.openReceiver(String address, ReceiverOptions receiverOptions) Creates a receiver used to consume messages from the given node address.openSender(String address) Creates a sender used to send messages to the given node address.openSender(String address, SenderOptions senderOptions) Creates a sender used to send messages to the given node address.Returns the properties that the remote provided upon successfully opening theSession.Roll back the currently active transaction in this Session.
- 
Method Details- 
client- Specified by:
- clientin interface- Session
- Returns:
- the Clientinstance that holds this session'sConnection
 
- 
connection- Specified by:
- connectionin interface- Session
- Returns:
- the Connectionthat created and holds thisSession.
 
- 
openFuture- Specified by:
- openFuturein interface- Session
- Returns:
- a Futurethat will be completed when the remote opens thisSession.
 
- 
closepublic void close()Description copied from interface:SessionRequests a close of theSessionat the remote and waits until the Session has been fully closed or until the configuredSessionOptions.closeTimeout()is exceeded.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Session
 
- 
closeDescription copied from interface:SessionRequests a close of theSessionat the remote and waits until the Session has been fully closed or until the configuredSessionOptions.closeTimeout()is exceeded.- Specified by:
- closein interface- Session
- Parameters:
- error- The- ErrorConditionto transmit to the remote along with the close operation.
 
- 
closeAsyncDescription copied from interface:SessionRequests a close of theSessionat the remote and returns aFuturethat will be completed once the session has been remotely closed or an error occurs.- Specified by:
- closeAsyncin interface- Session
- Returns:
- a Futurethat will be completed when the remote closes thisSession.
 
- 
closeAsyncDescription copied from interface:SessionRequests a close of theSessionat the remote and returns aFuturethat will be completed once the session has been remotely closed or an error occurs.- Specified by:
- closeAsyncin interface- Session
- Parameters:
- error- The- ErrorConditionto transmit to the remote along with the close operation.
- Returns:
- a Futurethat will be completed when the remote closes thisSession.
 
- 
openReceiverDescription copied from interface:SessionCreates a receiver used to consume messages from the given node address.- Specified by:
- openReceiverin interface- Session
- Parameters:
- address- The source address to attach the consumer to.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openReceiverpublic Receiver openReceiver(String address, ReceiverOptions receiverOptions) throws ClientException Description copied from interface:SessionCreates a receiver used to consume messages from the given node address.- Specified by:
- openReceiverin interface- Session
- Parameters:
- address- The source address to attach the consumer to.
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDurableReceiverDescription copied from interface:SessionCreates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.- Specified by:
- openDurableReceiverin interface- Session
- Parameters:
- address- The source address to attach the consumer to.
- subscriptionName- The name to give the subscription (link name).
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDurableReceiverpublic Receiver openDurableReceiver(String address, String subscriptionName, ReceiverOptions receiverOptions) throws ClientException Description copied from interface:SessionCreates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.- Specified by:
- openDurableReceiverin interface- Session
- Parameters:
- address- The source address to attach the consumer to.
- subscriptionName- The name to give the subscription (link name).
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverDescription copied from interface:SessionCreates a dynamic receiver used to consume messages from the given node address.- Specified by:
- openDynamicReceiverin interface- Session
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverpublic Receiver openDynamicReceiver(Map<String, Object> dynamicNodeProperties) throws ClientExceptionDescription copied from interface:SessionCreates a dynamic receiver used to consume messages from the given node address.- Specified by:
- openDynamicReceiverin interface- Session
- Parameters:
- dynamicNodeProperties- The dynamic node properties to be applied to the node created by the remote.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverDescription copied from interface:SessionCreates a dynamic receiver used to consume messages from the given node address.- Specified by:
- openDynamicReceiverin interface- Session
- Parameters:
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverpublic Receiver openDynamicReceiver(Map<String, Object> dynamicNodeProperties, ReceiverOptions receiverOptions) throws ClientExceptionDescription copied from interface:SessionCreates a dynamic receiver used to consume messages from the given node address.- Specified by:
- openDynamicReceiverin interface- Session
- Parameters:
- dynamicNodeProperties- The dynamic node properties to be applied to the node created by the remote.
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiver
- Throws:
- ClientException- if an internal error occurs.
 
- 
openSenderDescription copied from interface:SessionCreates a sender used to send messages to the given node address. If no address (i.e null) is specified then a sender will be established to the 'anonymous relay' and each message must specify its destination address.- Specified by:
- openSenderin interface- Session
- Parameters:
- address- The target address to attach to, or null to attach to the anonymous relay.
- Returns:
- the newly created Sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openSenderDescription copied from interface:SessionCreates a sender used to send messages to the given node address. If no address (i.e null) is specified then a sender will be established to the 'anonymous relay' and each message must specify its destination address.- Specified by:
- openSenderin interface- Session
- Parameters:
- address- The target address to attach to, or null to attach to the anonymous relay.
- senderOptions- The options for this sender.
- Returns:
- the newly created Sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openAnonymousSenderDescription copied from interface:SessionCreates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.- Specified by:
- openAnonymousSenderin interface- Session
- Returns:
- the newly created Sender.
- Throws:
- ClientException- if an internal error occurs.
- ClientUnsupportedOperationException- if the remote did not signal support for anonymous relays.
 
- 
openAnonymousSenderDescription copied from interface:SessionCreates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.- Specified by:
- openAnonymousSenderin interface- Session
- Parameters:
- senderOptions- The options for this sender.
- Returns:
- the newly created Sender.
- Throws:
- ClientException- if an internal error occurs.
- ClientUnsupportedOperationException- if the remote did not signal support for anonymous relays.
 
- 
propertiesDescription copied from interface:SessionReturns the properties that the remote provided upon successfully opening theSession. If the open has not completed yet this method will block to await the open response which carries the remote properties. If the remote provides no properties this method will return null.- Specified by:
- propertiesin interface- Session
- Returns:
- any properties provided from the remote once the session has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Sessionremote properties.
 
- 
offeredCapabilitiesDescription copied from interface:SessionReturns the offered capabilities that the remote provided upon successfully opening theSession. If the open has not completed yet this method will block to await the open response which carries the remote offered capabilities. If the remote provides no capabilities this method will return null.- Specified by:
- offeredCapabilitiesin interface- Session
- Returns:
- any capabilities provided from the remote once the session has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Sessionremote offered capabilities.
 
- 
desiredCapabilitiesDescription copied from interface:SessionReturns the desired capabilities that the remote provided upon successfully opening theSession. If the open has not completed yet this method will block to await the open response which carries the remote desired capabilities. If the remote provides no capabilities this method will return null.- Specified by:
- desiredCapabilitiesin interface- Session
- Returns:
- any desired capabilities provided from the remote once the session has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Sessionremote desired capabilities.
 
- 
beginTransactionDescription copied from interface:SessionOpens a new transaction scoped to thisSessionif one is not already active. ASessionthat has an active transaction will perform all sends and all delivery dispositions under that active transaction. If the user wishes to send with the same session but outside of a transaction the user must commit the active transaction and not request that a new one be started. A session can only have one active transaction at a time and as such any call to begin while there is a currently active transaction will throw anClientIllegalStateExceptionto indicate that the operation being requested is not valid at that time. This is a blocking method that will return successfully only after a new transaction has been started.- Specified by:
- beginTransactionin interface- Session
- Returns:
- this Sessioninstance.
- Throws:
- ClientException- if an error occurs while attempting to begin a new transaction.
 
- 
commitTransactionDescription copied from interface:SessionCommit the currently active transaction in this Session. Commit the currently active transaction in this Session but does not start a new transaction automatically. If there is no current transaction this method will throw anClientTransactionNotActiveExceptionto indicate this error. If the active transaction has entered an in doubt state or was remotely rolled back this method will throw an error to indicate that the commit failed and that a new transaction need to be started by the user. When a transaction rolled back error occurs the user should assume that all work performed under that transaction has failed and will need to be attempted under a new transaction. This is a blocking method that will return successfully only after the current transaction has been committed.- Specified by:
- commitTransactionin interface- Session
- Returns:
- this Sessioninstance.
- Throws:
- ClientException- if an error occurs while attempting to commit the current transaction.
 
- 
rollbackTransactionDescription copied from interface:SessionRoll back the currently active transaction in this Session. Roll back the currently active transaction in this Session but does not automatically start a new transaction. If there is no current transaction this method will throw anClientTransactionNotActiveExceptionto indicate this error. If the active transaction has entered an in doubt state or was remotely rolled back this method will throw an error to indicate that the roll back failed and that a new transaction need to be started by the user.- Specified by:
- rollbackTransactionin interface- Session
- Returns:
- this Sessioninstance.
- Throws:
- ClientException- if an error occurs while attempting to roll back the current transaction.
 
- 
nextReceiverDescription copied from interface:SessionWaits indefinitely for a receiver created from this session to have a delivery ready for receipt. The selection of the next receiver when more than one exits which has pending deliveries is based upon the configured value of theSessionOptions.defaultNextReceiverPolicy()used to create this session or if none was provided then the value is taken from the value of theConnectionOptions.defaultNextReceiverPolicy().- Specified by:
- nextReceiverin interface- Session
- Returns:
- the next receiver that has a pending delivery available based on policy.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverDescription copied from interface:SessionWaits for the given duration for a receiver created from this session to have a delivery ready for receipt. The selection of the next receiver when more than one exits which has pending deliveries is based upon the configured value of theSessionOptions.defaultNextReceiverPolicy()used to create this session or if none was provided then the value is taken from the value of theConnectionOptions.defaultNextReceiverPolicy(). If no receiver has an available delivery within the given timeout this method returns null.- Specified by:
- nextReceiverin interface- Session
- Parameters:
- timeout- The timeout value used to control how long the method waits for a new- Deliveryto be available.
- unit- The unit of time that the given timeout represents.
- Returns:
- the next receiver that has a pending delivery available based on policy.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverDescription copied from interface:SessionWaits indefinitely for a receiver created from this session to have a delivery ready for receipt. The selection of the next receiver when more than one exits which has pending deliveries is based upon the value of theNextReceiverPolicythat is provided by the caller.- Specified by:
- nextReceiverin interface- Session
- Parameters:
- policy- The policy to apply when selecting the next receiver.
- Returns:
- the next receiver that has a pending delivery available based on policy.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverpublic Receiver nextReceiver(NextReceiverPolicy policy, long timeout, TimeUnit unit) throws ClientException Description copied from interface:SessionWaits for the given duration for a receiver created from this session to have a delivery ready for receipt. The selection of the next receiver when more than one exits which has pending deliveries is based upon the value of theNextReceiverPolicyprovided by the caller. If no receiver has an available delivery within the given timeout this method returns null.- Specified by:
- nextReceiverin interface- Session
- Parameters:
- policy- The policy to apply when selecting the next receiver.
- timeout- The timeout value used to control how long the method waits for a new- Deliveryto be available.
- unit- The unit of time that the given timeout represents.
- Returns:
- the next receiver that has a pending delivery available based on policy.
- Throws:
- ClientException- if an internal error occurs.
 
- 
checkClosedOrFailed- Throws:
- ClientException
 
 
-