Class ClientStreamSender
- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientStreamSender
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,Sender
,StreamSender
public final class ClientStreamSender extends java.lang.Object implements StreamSender
Client implementation of aStreamSender
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Deque<ClientOutgoingEnvelope>
blocked
protected int
closed
protected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<org.apache.qpid.protonj2.client.impl.ClientSender>
CLOSED_UPDATER
protected ClientFuture<Sender>
closeFuture
protected java.util.concurrent.ScheduledExecutorService
executor
protected ClientException
failureCause
protected ClientFuture<Sender>
openFuture
protected Sender
protonSender
protected Source
remoteSource
protected Target
remoteTarget
protected java.lang.String
senderId
protected java.util.function.Consumer<Sender>
senderRemotelyClosedHandler
protected boolean
sendsSettled
protected ClientSession
session
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
address()
protected void
addToHeadOfBlockedQueue(ClientOutgoingEnvelope send)
protected void
addToTailOfBlockedQueue(ClientOutgoingEnvelope send)
org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessage
beginMessage()
Creates and returns a newStreamSenderMessage
that can be used by the caller to perform streaming sends of large message payload data.org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessage
beginMessage(java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations)
Creates and returns a newStreamSenderMessage
that can be used by the caller to perform streaming sends of large message payload data.protected void
checkClosedOrFailed()
ClientInstance
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.ClientFuture<Sender>
closeAsync()
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.ClientFuture<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.ClientConnection
connection()
protected ClientNoOpStreamTracker
createNoOpTracker()
protected ClientStreamTracker
createTracker(OutgoingDelivery delivery)
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.ClientFuture<Sender>
detachAsync()
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.ClientFuture<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.protected boolean
notClosedOrFailed(ClientFuture<?> request)
java.lang.String[]
offeredCapabilities()
Returns the offered capabilities that the remote provided upon successfully opening theSender
.ClientFuture<Sender>
openFuture()
java.util.Map<java.lang.String,java.lang.Object>
properties()
Returns the properties that the remote provided upon successfully opening theSender
.StreamTracker
send(Message<?> message)
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.StreamTracker
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.protected Tracker
sendMessage(AdvancedMessage<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations, boolean waitForCredit)
ClientSession
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.StreamTracker
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.StreamTracker
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.qpid.protonj2.client.Sender
address, client, close, close, closeAsync, closeAsync, connection, desiredCapabilities, detach, detach, detachAsync, detachAsync, offeredCapabilities, openFuture, properties, session, source, target
-
-
-
-
Field Detail
-
CLOSED_UPDATER
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<org.apache.qpid.protonj2.client.impl.ClientSender> CLOSED_UPDATER
-
openFuture
protected final ClientFuture<Sender> openFuture
-
closeFuture
protected final ClientFuture<Sender> closeFuture
-
closed
protected volatile int closed
-
failureCause
protected ClientException failureCause
-
blocked
protected final java.util.Deque<ClientOutgoingEnvelope> blocked
-
session
protected final ClientSession session
-
executor
protected final java.util.concurrent.ScheduledExecutorService executor
-
senderId
protected final java.lang.String senderId
-
sendsSettled
protected final boolean sendsSettled
-
protonSender
protected Sender protonSender
-
senderRemotelyClosedHandler
protected java.util.function.Consumer<Sender> senderRemotelyClosedHandler
-
remoteSource
protected volatile Source remoteSource
-
remoteTarget
protected volatile Target remoteTarget
-
-
Method Detail
-
send
public StreamTracker send(Message<?> message) throws ClientException
Description copied from interface:Sender
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Specified by:
send
in interfaceSender
- Parameters:
message
- theMessage
to send.- Returns:
- the
Tracker
for the message delivery - Throws:
ClientException
- if an error occurs while initiating the send operation.
-
send
public StreamTracker send(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Description copied from interface:Sender
Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Specified by:
send
in interfaceSender
- 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
public StreamTracker trySend(Message<?> message) throws ClientException
Description copied from interface:Sender
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.- Specified by:
trySend
in interfaceSender
- 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
public StreamTracker trySend(Message<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Description copied from interface:Sender
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.- Specified by:
trySend
in interfaceSender
- 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.
-
beginMessage
public org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessage beginMessage() throws ClientException
Description copied from interface:StreamSender
Creates and returns a newStreamSenderMessage
that can be used by the caller to perform streaming sends of large message payload data.- Specified by:
beginMessage
in interfaceStreamSender
- Returns:
- a new
StreamSenderMessage
that can be used to stream message data to the remote. - Throws:
ClientException
- if an error occurs while initiating a new streaming send message.
-
beginMessage
public org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessage beginMessage(java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations) throws ClientException
Description copied from interface:StreamSender
Creates and returns a newStreamSenderMessage
that can be used by the caller to perform streaming sends of large message payload data.- Specified by:
beginMessage
in interfaceStreamSender
- Parameters:
deliveryAnnotations
- the delivery annotations that should be included in the sentStreamSenderMessage
.- Returns:
- a new
StreamSenderMessage
that can be used to stream message data to the remote. - Throws:
ClientException
- if an error occurs while initiating a new streaming send message.
-
createTracker
protected ClientStreamTracker createTracker(OutgoingDelivery delivery)
-
createNoOpTracker
protected ClientNoOpStreamTracker createNoOpTracker()
-
address
public java.lang.String address() throws ClientException
Description copied from interface:Sender
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.
- Specified by:
address
in interfaceSender
- Returns:
- the address that this
Sender
is sending to. - Throws:
ClientException
- if an error occurs while obtaining theSender
address.
-
source
public Source source() throws ClientException
Description copied from interface:Sender
-
target
public Target target() throws ClientException
Description copied from interface:Sender
-
client
public ClientInstance client()
-
connection
public ClientConnection connection()
- Specified by:
connection
in interfaceSender
- Returns:
- the
Connection
instance that holds this session'sSender
-
session
public ClientSession session()
-
openFuture
public ClientFuture<Sender> openFuture()
- Specified by:
openFuture
in interfaceSender
- Returns:
- a
Future
that will be completed when the remote opens thisSender
.
-
close
public void close()
Description copied from interface:Sender
Requests a close of theSender
at the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()
is exceeded.
-
close
public void close(ErrorCondition error)
Description copied from interface:Sender
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 interfaceSender
- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the close operation.
-
detach
public void detach()
Description copied from interface:Sender
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
public void detach(ErrorCondition error)
Description copied from interface:Sender
Requests a detach of theSender
at the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()
is exceeded.- Specified by:
detach
in interfaceSender
- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the detach operation.
-
closeAsync
public ClientFuture<Sender> closeAsync()
Description copied from interface:Sender
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.- Specified by:
closeAsync
in interfaceSender
- Returns:
- a
Future
that will be completed when the remote closes thisSender
link.
-
closeAsync
public ClientFuture<Sender> closeAsync(ErrorCondition error)
Description copied from interface:Sender
Requests a close of theSender
link at the remote and returns aFuture
that will be completed once the link has been closed.- Specified by:
closeAsync
in interfaceSender
- 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
public ClientFuture<Sender> detachAsync()
Description copied from interface:Sender
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.- Specified by:
detachAsync
in interfaceSender
- Returns:
- a
Future
that will be completed when the remote detaches thisSender
link.
-
detachAsync
public ClientFuture<Sender> detachAsync(ErrorCondition error)
Description copied from interface:Sender
Requests a detach of theSender
link at the remote and returns aFuture
that will be completed once the link has been detached.- Specified by:
detachAsync
in interfaceSender
- 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.
-
properties
public java.util.Map<java.lang.String,java.lang.Object> properties() throws ClientException
Description copied from interface:Sender
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.- Specified by:
properties
in interfaceSender
- 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
public java.lang.String[] offeredCapabilities() throws ClientException
Description copied from interface:Sender
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.- Specified by:
offeredCapabilities
in interfaceSender
- 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
public java.lang.String[] desiredCapabilities() throws ClientException
Description copied from interface:Sender
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.- Specified by:
desiredCapabilities
in interfaceSender
- 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.
-
addToTailOfBlockedQueue
protected final void addToTailOfBlockedQueue(ClientOutgoingEnvelope send)
-
addToHeadOfBlockedQueue
protected final void addToHeadOfBlockedQueue(ClientOutgoingEnvelope send)
-
sendMessage
protected Tracker sendMessage(AdvancedMessage<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations, boolean waitForCredit) throws ClientException
- Throws:
ClientException
-
notClosedOrFailed
protected boolean notClosedOrFailed(ClientFuture<?> request)
-
checkClosedOrFailed
protected void checkClosedOrFailed() throws ClientException
- Throws:
ClientException
-
-