Class ClientConnection
java.lang.Object
org.apache.qpid.protonj2.client.impl.ClientConnection
- All Implemented Interfaces:
- AutoCloseable,- Connection
A 
Connection implementation that uses the Proton engine for AMQP protocol support.- 
Method SummaryModifier and TypeMethodDescriptionprotected voidclient()voidclose()Requests a close of theConnectionat the remote and waits until the Connection has been fully closed or until the configuredConnectionOptions.closeTimeout()is exceeded.voidclose(ErrorCondition error) Requests a close of theConnectionat the remote and waits until the Connection has been fully closed or until the configuredConnectionOptions.closeTimeout()is exceeded.Requests a close of theConnectionat the remote and returns aFuturethat will be completed once the Connection has been fully closed.closeAsync(ErrorCondition error) Requests a close of theConnectionat the remote and returns aFuturethat will be completed once the Connection has been fully closed.Returns the default anonymous sender used by thisConnectionforConnection.send(Message)calls.String[]Returns the desired capabilities that the remote provided upon successfully opening theConnection.Waits indefinitely for a receiver created from the connection default session to have a delivery ready for receipt.nextReceiver(long timeout, TimeUnit unit) Waits for the configured time interval for a receiver created from the connection default session to have a delivery ready for receipt.nextReceiver(NextReceiverPolicy policy) Waits indefinitely for a receiver created from the connection default session to have a delivery ready for receipt.nextReceiver(NextReceiverPolicy policy, long timeout, TimeUnit unit) Waits for the configured time interval for a receiver created from the connection default session to have a delivery ready for receipt.String[]Returns the offered capabilities that the remote provided upon successfully opening theConnection.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 a dynamically generated node on the remote..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 a dynamically generated node on the remote..When aConnectionis created it may not be opened on the remote peer, the future returned from this method allows the caller to await the completion of the Connection open by the remote before proceeding on to other messaging operations.openReceiver(String address) Creates a receiver used to consumer messages from the given node address.openReceiver(String address, ReceiverOptions receiverOptions) Creates a receiver used to consumer 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.Creates a newSessioninstance for use by the client application.openSession(SessionOptions sessionOptions) Creates a newSessioninstance for use by the client application.openStreamReceiver(String address) Creates a streaming message receiver used to consume large messages from the given node address.openStreamReceiver(String address, StreamReceiverOptions receiverOptions) Creates a streaming message receiver used to consume large messages from the given node address.openStreamSender(String address) Creates a stream sender used to send large messages to the given node address.openStreamSender(String address, StreamSenderOptions senderOptions) Creates a streaming sender used to send large messages to the given node address.Returns the properties that the remote provided upon successfully opening theConnection.Sends the givenMessageusing the internal connection sender.toString()
- 
Method Details- 
client- Specified by:
- clientin interface- Connection
- Returns:
- the Clientinstance that holds thisConnection
 
- 
openFutureDescription copied from interface:ConnectionWhen aConnectionis created it may not be opened on the remote peer, the future returned from this method allows the caller to await the completion of the Connection open by the remote before proceeding on to other messaging operations. If the open of the connection fails at the remote anExceptionis thrown from theFuture.get()method when called.- Specified by:
- openFuturein interface- Connection
- Returns:
- a Futurethat will be completed when the remote opens thisConnection.
 
- 
closepublic void close()Description copied from interface:ConnectionRequests a close of theConnectionat the remote and waits until the Connection has been fully closed or until the configuredConnectionOptions.closeTimeout()is exceeded.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Connection
 
- 
closeDescription copied from interface:ConnectionRequests a close of theConnectionat the remote and waits until the Connection has been fully closed or until the configuredConnectionOptions.closeTimeout()is exceeded.- Specified by:
- closein interface- Connection
- Parameters:
- error- The- ErrorConditionto transmit to the remote along with the close operation.
 
- 
closeAsyncDescription copied from interface:ConnectionRequests a close of theConnectionat the remote and returns aFuturethat will be completed once the Connection has been fully closed.- Specified by:
- closeAsyncin interface- Connection
- Returns:
- a Futurethat will be completed when the remote closes thisConnection.
 
- 
closeAsyncDescription copied from interface:ConnectionRequests a close of theConnectionat the remote and returns aFuturethat will be completed once the Connection has been fully closed.- Specified by:
- closeAsyncin interface- Connection
- Parameters:
- error- The- ErrorConditionto transmit to the remote along with the close operation.
- Returns:
- a Futurethat will be completed when the remote closes thisConnection.
 
- 
defaultSessionDescription copied from interface:ConnectionReturns the defaultSessioninstance that is used by this Connection to create the default anonymous connectionSenderas well as creating those resources created from theConnectionsuch asSenderandReceiverinstances not married to a specificSession.While it is possible to use the returned Session to cause Connection level resources to operate within a transaction it is strongly discouraged. Transactions should be performed from a user created Session with a single SenderorReceiverlink for best results.- Specified by:
- defaultSessionin interface- Connection
- Returns:
- a new Sessioninstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openSessionDescription copied from interface:ConnectionCreates a newSessioninstance for use by the client application. The returned session will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returnedSessionmay not have been opened on the remote when it is returned. Some methods of theSessioncan block until the remote fully opens the session, the user can wait for the remote to respond to the open request by calling theSession.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openSessionin interface- Connection
- Returns:
- a new Sessioninstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openSessionDescription copied from interface:ConnectionCreates a newSessioninstance for use by the client application. The returnedSessionmay not have been opened on the remote when it is returned. Some methods of theSessioncan block until the remote fully opens the session, the user can wait for the remote to respond to the open request by calling theSession.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openSessionin interface- Connection
- Parameters:
- sessionOptions- The- SessionOptionsthat control properties of the created session.
- Returns:
- a new Sessioninstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openReceiverDescription copied from interface:ConnectionCreates a receiver used to consumer messages from the given node address. The returned receiver will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openReceiverin interface- Connection
- Parameters:
- address- The source address to attach the consumer to.
- Returns:
- the consumer.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openReceiverpublic Receiver openReceiver(String address, ReceiverOptions receiverOptions) throws ClientException Description copied from interface:ConnectionCreates a receiver used to consumer messages from the given node address. The returned receiver will be configured using the options provided in the givenReceiverOptionsinstance. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openReceiverin interface- Connection
- Parameters:
- address- The source address to attach the consumer to.
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDurableReceiverDescription copied from interface:ConnectionCreates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node. The returned receiver will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDurableReceiverin interface- Connection
- Parameters:
- address- The source address to attach the consumer to.
- subscriptionName- The name to give the subscription (link name).
- Returns:
- the newly created Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDurableReceiverpublic Receiver openDurableReceiver(String address, String subscriptionName, ReceiverOptions receiverOptions) throws ClientException Description copied from interface:ConnectionCreates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node. The returned receiver will be configured using provided options. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDurableReceiverin interface- Connection
- 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 Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverDescription copied from interface:ConnectionCreates a dynamic receiver used to consume messages from the given node address. The returned receiver will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDynamicReceiverin interface- Connection
- Returns:
- the newly created Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverpublic Receiver openDynamicReceiver(Map<String, Object> dynamicNodeProperties) throws ClientExceptionDescription copied from interface:ConnectionCreates a dynamic receiver used to consume messages from a dynamically generated node on the remote.. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDynamicReceiverin interface- Connection
- Parameters:
- dynamicNodeProperties- The dynamic node properties to be applied to the node created by the remote.
- Returns:
- the newly created Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverDescription copied from interface:ConnectionCreates a dynamic receiver used to consume messages from a dynamically generated node on the remote.. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDynamicReceiverin interface- Connection
- Parameters:
- receiverOptions- The options for this receiver.
- Returns:
- the newly created Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openDynamicReceiverpublic Receiver openDynamicReceiver(Map<String, Object> dynamicNodeProperties, ReceiverOptions receiverOptions) throws ClientExceptionDescription copied from interface:ConnectionCreates a dynamic receiver used to consume messages from the given node address. The returned receiver may not have been opened on the remote when it is returned. Some methods of theReceivercan block until the remote fully opens the receiver, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openDynamicReceiverin interface- Connection
- 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 Receiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openStreamReceiverDescription copied from interface:ConnectionCreates a streaming message receiver used to consume large messages from the given node address. The returnedStreamReceiverwill be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returned stream receiver may not have been opened on the remote when it is returned. Some methods of theStreamReceivercan block until the remote fully opens the receiver link, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openStreamReceiverin interface- Connection
- Parameters:
- address- The source address to attach the consumer to.
- Returns:
- the newly created StreamReceiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openStreamReceiverpublic StreamReceiver openStreamReceiver(String address, StreamReceiverOptions receiverOptions) throws ClientException Description copied from interface:ConnectionCreates a streaming message receiver used to consume large messages from the given node address. The returned receiver will be configured using the options provided in the givenReceiverOptionsinstance. The returnedStreamReceivermay not have been opened on the remote when it is returned. Some methods of theStreamReceivercan block until the remote fully opens the receiver link, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openStreamReceiverin interface- Connection
- Parameters:
- address- The source address to attach the consumer to.
- receiverOptions- The options for this receiver.
- Returns:
- the newly created StreamReceiverinstance.
- Throws:
- ClientException- if an internal error occurs.
 
- 
defaultSenderDescription copied from interface:ConnectionReturns the default anonymous sender used by thisConnectionforConnection.send(Message)calls. If the sender has not been created yet this call will initiate its creation and open with the remote peer.- Specified by:
- defaultSenderin interface- Connection
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs opening the default sender.
- ClientUnsupportedOperationException- if the remote did not signal support for anonymous relays.
 
- 
openSenderDescription copied from interface:ConnectionCreates a sender used to send messages to the given node address. The returned sender will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returnedSendermay not have been opened on the remote when it is returned. Some methods of theSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openSenderin interface- Connection
- Parameters:
- address- The target address to attach to, cannot be null.
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openSenderDescription copied from interface:ConnectionCreates a sender used to send messages to the given node address. The returnedSendermay not have been opened on the remote when it is returned. Some methods of theSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openSenderin interface- Connection
- Parameters:
- address- The target address to attach to, cannot be null.
- senderOptions- The options for this sender.
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openAnonymousSenderDescription copied from interface:ConnectionCreates 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. The returned sender will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returnedSendermay not have been opened on the remote when it is returned. Some methods of theSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openAnonymousSenderin interface- Connection
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs.
- ClientUnsupportedOperationException- if the remote did not signal support for anonymous relays.
 
- 
openAnonymousSenderDescription copied from interface:ConnectionCreates 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. The returnedSendermay not have been opened on the remote when it is returned. Some methods of theSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openAnonymousSenderin interface- Connection
- Parameters:
- senderOptions- The options for this sender.
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs.
- ClientUnsupportedOperationException- if the remote did not signal support for anonymous relays.
 
- 
openStreamSenderDescription copied from interface:ConnectionCreates a stream sender used to send large messages to the given node address. The returned sender will be configured using default options and will take its timeout configuration values from those specified in the parentConnection. The returnedStreamSendermay not have been opened on the remote when it is returned. Some methods of theStreamSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openStreamSenderin interface- Connection
- Parameters:
- address- The target address to attach to, cannot be null.
- Returns:
- the stream sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
openStreamSenderpublic StreamSender openStreamSender(String address, StreamSenderOptions senderOptions) throws ClientException Description copied from interface:ConnectionCreates a streaming sender used to send large messages to the given node address.The returned StreamSendermay not have been opened on the remote when it is returned. Some methods of theStreamSendercan block until the remote fully opens the sender, the user can wait for the remote to respond to the open request by calling theLink.openFuture()method and using theFuture.get()methods to wait for completion.- Specified by:
- openStreamSenderin interface- Connection
- Parameters:
- address- The target address to attach to, cannot be null.
- senderOptions- The options for this sender.
- Returns:
- the sender.
- Throws:
- ClientException- if an internal error occurs.
 
- 
sendDescription copied from interface:ConnectionSends the givenMessageusing the internal connection sender.The connection Senderis an anonymous AMQP sender which requires that the given message has a valid to value set.- Specified by:
- sendin interface- Connection
- Parameters:
- message- The message to send
- Returns:
- a Trackerthat allows the client to track settlement of the message.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverDescription copied from interface:ConnectionWaits indefinitely for a receiver created from the connection default session to have a delivery ready for receipt. The selection of the next receiver when more than one exists which has pending deliveries is based upon the configured value of theConnectionOptions.defaultNextReceiverPolicy().- Specified by:
- nextReceiverin interface- Connection
- Returns:
- the next receiver that has a pending delivery available based on policy.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverDescription copied from interface:ConnectionWaits for the configured time interval for a receiver created from the connection default session to have a delivery ready for receipt. The selection of the next receiver when more than one exists which has pending deliveries is based upon the configured value of theConnectionOptions.defaultNextReceiverPolicy(). If no receiver has an incoming delivery before the given timeout expires the method returns null.- Specified by:
- nextReceiverin interface- Connection
- 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 or null if the timeout is reached.
- Throws:
- ClientException- if an internal error occurs.
 
- 
nextReceiverDescription copied from interface:ConnectionWaits indefinitely for a receiver created from the connection default session to have a delivery ready for receipt. The selection of the next receiver when more than one exists which has pending deliveries is based upon the value of theNextReceiverPolicythat is provided by the caller.- Specified by:
- nextReceiverin interface- Connection
- 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:ConnectionWaits for the configured time interval for a receiver created from the connection default session to have a delivery ready for receipt. The selection of the next receiver when more than one exists which has pending deliveries is based upon theNextReceiverPolicyprovided by the caller. If no receiver has an incoming delivery before the given timeout expires the method returns null.- Specified by:
- nextReceiverin interface- Connection
- 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 or null if the timeout is reached.
- Throws:
- ClientException- if an internal error occurs.
 
- 
propertiesDescription copied from interface:ConnectionReturns the properties that the remote provided upon successfully opening theConnection. 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- Connection
- Returns:
- any properties provided from the remote once the connection has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Connectionremote properties.
 
- 
offeredCapabilitiesDescription copied from interface:ConnectionReturns the offered capabilities that the remote provided upon successfully opening theConnection. 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- Connection
- Returns:
- any capabilities provided from the remote once the connection has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Connectionremote offered capabilities.
 
- 
desiredCapabilitiesDescription copied from interface:ConnectionReturns the desired capabilities that the remote provided upon successfully opening theConnection. 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- Connection
- Returns:
- any desired capabilities provided from the remote once the connection has successfully opened.
- Throws:
- ClientException- if an error occurs while obtaining the- Connectionremote desired capabilities.
 
- 
toString
- 
checkClosedOrFailed- Throws:
- ClientException
 
 
-