Package org.apache.qpid.protonj2.client
Interface Sender
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Subinterfaces:
StreamSender
- All Known Implementing Classes:
ClientStreamSender
public interface Sender extends java.lang.AutoCloseable
AMQP Sender that provides an API for sending complete Message payload data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
address()
Client
client()
void
close()
Requests a close of theSender
at the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()
is exceeded.void
close(ErrorCondition error)
Requests a close of theSender
at the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()
is exceeded.java.util.concurrent.Future<Sender>
closeAsync()
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.java.util.concurrent.Future<Sender>
closeAsync(ErrorCondition error)
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.Connection
connection()
java.lang.String[]
desiredCapabilities()
Returns the desired capabilities that the remote provided upon successfully opening theSender
.void
detach()
Requests a detach of theSender
at the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()
is exceeded.void
detach(ErrorCondition error)
Requests a detach of theSender
at the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()
is exceeded.java.util.concurrent.Future<Sender>
detachAsync()
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.java.util.concurrent.Future<Sender>
detachAsync(ErrorCondition error)
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.java.lang.String[]
offeredCapabilities()
Returns the offered capabilities that the remote provided upon successfully opening theSender
.java.util.concurrent.Future<Sender>
openFuture()
java.util.Map<java.lang.String,java.lang.Object>
properties()
Returns the properties that the remote provided upon successfully opening theSender
.Tracker
send(Message<?> message)
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.Tracker
send(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations)
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.Session
session()
Source
source()
Returns an immutable view of the remoteSource
object assigned to this sender link.Target
target()
Returns an immutable view of the remoteTarget
object assigned to this sender link.Tracker
trySend(Message<?> message)
Send the given message if credit is available or returns null if no credit has been granted to the link at the time of the send attempt.Tracker
trySend(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations)
Send the given message if credit is available or returns null if no credit has been granted to the link at the time of the send attempt.
-
-
-
Method Detail
-
openFuture
java.util.concurrent.Future<Sender> openFuture()
- Returns:
- a
Future
that will be completed when the remote opens thisSender
.
-
close
void close()
Requests a close of theSender
at the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()
is exceeded.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
close
void close(ErrorCondition error)
Requests a close of theSender
at the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()
is exceeded.- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the close operation.
-
detach
void detach()
Requests a detach of theSender
at the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()
is exceeded.
-
detach
void detach(ErrorCondition error)
Requests a detach of theSender
at the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()
is exceeded.- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the detach operation.
-
closeAsync
java.util.concurrent.Future<Sender> closeAsync()
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.- Returns:
- a
Future
that will be completed when the remote closes thisSender
link.
-
closeAsync
java.util.concurrent.Future<Sender> closeAsync(ErrorCondition error)
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the close operation.- Returns:
- a
Future
that will be completed when the remote closes thisSender
link.
-
detachAsync
java.util.concurrent.Future<Sender> detachAsync()
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.- Returns:
- a
Future
that will be completed when the remote detaches thisSender
link.
-
detachAsync
java.util.concurrent.Future<Sender> detachAsync(ErrorCondition error)
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the detach operation.- Returns:
- a
Future
that will be completed when the remote detaches thisSender
link.
-
address
java.lang.String address() throws ClientException
Returns the address that theSender
instance will sendMessage
objects to. The value returned from this method is control by the configuration that was used to create the sender.- If the Sender is configured as an anonymous sender then this method returns null.
- If the Sender was created with the dynamic sender methods then the method will return the dynamically created address once the remote has attached its end of the sender link. Due to the need to await the remote peer to populate the dynamic address this method will block until the open of the sender link has completed.
-
If neither of the above is true then the address returned is the address passed to the original
Session.openSender(String)
orSession.openSender(String, SenderOptions)
methods.
- Returns:
- the address that this
Sender
is sending to. - Throws:
ClientException
- if an error occurs while obtaining theSender
address.
-
source
Source source() throws ClientException
Returns an immutable view of the remoteSource
object assigned to this sender link. If the attach has not completed yet this method will block to await the attach response which carries the remoteSource
.- Returns:
- the remote
Source
node configuration. - Throws:
ClientException
- if an error occurs while obtaining theSender
remoteSource
.
-
target
Target target() throws ClientException
Returns an immutable view of the remoteTarget
object assigned to this sender link. If the attach has not completed yet this method will block to await the attach response which carries the remoteTarget
.- Returns:
- the remote
Target
node configuration. - Throws:
ClientException
- if an error occurs while obtaining theSender
remoteTarget
.
-
properties
java.util.Map<java.lang.String,java.lang.Object> properties() throws ClientException
Returns the properties that the remote provided upon successfully opening theSender
. If the attach has not completed yet this method will block to await the attach response which carries the remote properties. If the remote provides no properties this method will return null.- Returns:
- any properties provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theSender
remote properties.
-
offeredCapabilities
java.lang.String[] offeredCapabilities() throws ClientException
Returns the offered capabilities that the remote provided upon successfully opening theSender
. If the attach has not completed yet this method will block to await the attach response which carries the remote offered capabilities. If the remote provides no capabilities this method will return null.- Returns:
- any capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theSender
remote offered capabilities.
-
desiredCapabilities
java.lang.String[] desiredCapabilities() throws ClientException
Returns the desired capabilities that the remote provided upon successfully opening theSender
. If the attach has not completed yet this method will block to await the attach response which carries the remote desired capabilities. If the remote provides no capabilities this method will return null.- Returns:
- any desired capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theSender
remote desired capabilities.
-
connection
Connection connection()
- Returns:
- the
Connection
instance that holds this session'sSender
-
send
Tracker send(Message<?> message) throws ClientException
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Parameters:
message
- theMessage
to send.- Returns:
- the
Tracker
for the message delivery - Throws:
ClientException
- if an error occurs while initiating the send operation.
-
send
Tracker send(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Parameters:
message
- theMessage
to send.deliveryAnnotations
- the delivery annotations that should be included in the sentMessage
.- Returns:
- the
Tracker
for the message delivery - Throws:
ClientException
- if an error occurs while initiating the send operation.
-
trySend
Tracker trySend(Message<?> message) throws ClientException
Send the given message if credit is available or returns null if no credit has been granted to the link at the time of the send attempt.- Parameters:
message
- theMessage
to send if credit is available.- Returns:
- the
Tracker
for the message delivery or null if no credit for sending. - Throws:
ClientException
- if an error occurs while initiating the send operation.
-
trySend
Tracker trySend(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Send the given message if credit is available or returns null if no credit has been granted to the link at the time of the send attempt.- Parameters:
message
- theMessage
to send if credit is available.deliveryAnnotations
- the delivery annotations that should be included in the sentMessage
.- Returns:
- the
Tracker
for the message delivery or null if no credit for sending. - Throws:
ClientException
- if an error occurs while initiating the send operation.
-
-