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>blockedprotected intclosedprotected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<org.apache.qpid.protonj2.client.impl.ClientSender>CLOSED_UPDATERprotected ClientFuture<Sender>closeFutureprotected java.util.concurrent.ScheduledExecutorServiceexecutorprotected ClientExceptionfailureCauseprotected ClientFuture<Sender>openFutureprotected SenderprotonSenderprotected SourceremoteSourceprotected TargetremoteTargetprotected java.lang.StringsenderIdprotected java.util.function.Consumer<Sender>senderRemotelyClosedHandlerprotected booleansendsSettledprotected ClientSessionsession
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringaddress()protected voidaddToHeadOfBlockedQueue(ClientOutgoingEnvelope send)protected voidaddToTailOfBlockedQueue(ClientOutgoingEnvelope send)org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessagebeginMessage()Creates and returns a newStreamSenderMessagethat can be used by the caller to perform streaming sends of large message payload data.org.apache.qpid.protonj2.client.impl.ClientStreamSenderMessagebeginMessage(java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations)Creates and returns a newStreamSenderMessagethat can be used by the caller to perform streaming sends of large message payload data.protected voidcheckClosedOrFailed()ClientInstanceclient()voidclose()Requests a close of theSenderat the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()is exceeded.voidclose(ErrorCondition error)Requests a close of theSenderat 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 theSenderlink at the remote and returns aFuturethat will be completed once the link has been closed.ClientFuture<Sender>closeAsync(ErrorCondition error)Requests a close of theSenderlink at the remote and returns aFuturethat will be completed once the link has been closed.ClientConnectionconnection()protected ClientNoOpStreamTrackercreateNoOpTracker()protected ClientStreamTrackercreateTracker(OutgoingDelivery delivery)java.lang.String[]desiredCapabilities()Returns the desired capabilities that the remote provided upon successfully opening theSender.voiddetach()Requests a detach of theSenderat the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.voiddetach(ErrorCondition error)Requests a detach of theSenderat 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 theSenderlink at the remote and returns aFuturethat will be completed once the link has been detached.ClientFuture<Sender>detachAsync(ErrorCondition error)Requests a detach of theSenderlink at the remote and returns aFuturethat will be completed once the link has been detached.protected booleannotClosedOrFailed(ClientFuture<?> request)protected booleannotClosedOrFailed(ClientFuture<?> request, Sender sender)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.StreamTrackersend(Message<?> message)Send the given message immediately if there is credit available or blocks if the link has not yet been granted credit.StreamTrackersend(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 TrackersendMessage(AdvancedMessage<?> message, java.util.Map<java.lang.String,java.lang.Object> deliveryAnnotations, boolean waitForCredit)ClientSessionsession()Sourcesource()Returns an immutable view of the remoteSourceobject assigned to this sender link.Targettarget()Returns an immutable view of the remoteTargetobject assigned to this sender link.StreamTrackertrySend(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.StreamTrackertrySend(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:SenderSend the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Specified by:
sendin interfaceSender- Parameters:
message- theMessageto send.- Returns:
- the
Trackerfor 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:SenderSend the given message immediately if there is credit available or blocks if the link has not yet been granted credit.- Specified by:
sendin interfaceSender- Parameters:
message- theMessageto send.deliveryAnnotations- the delivery annotations that should be included in the sentMessage.- Returns:
- the
Trackerfor 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:SenderSend 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:
trySendin interfaceSender- Parameters:
message- theMessageto send if credit is available.- Returns:
- the
Trackerfor 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:SenderSend 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:
trySendin interfaceSender- Parameters:
message- theMessageto send if credit is available.deliveryAnnotations- the delivery annotations that should be included in the sentMessage.- Returns:
- the
Trackerfor 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 ClientExceptionDescription copied from interface:StreamSenderCreates and returns a newStreamSenderMessagethat can be used by the caller to perform streaming sends of large message payload data.- Specified by:
beginMessagein interfaceStreamSender- Returns:
- a new
StreamSenderMessagethat 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 ClientExceptionDescription copied from interface:StreamSenderCreates and returns a newStreamSenderMessagethat can be used by the caller to perform streaming sends of large message payload data.- Specified by:
beginMessagein interfaceStreamSender- Parameters:
deliveryAnnotations- the delivery annotations that should be included in the sentStreamSenderMessage.- Returns:
- a new
StreamSenderMessagethat 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 ClientExceptionDescription copied from interface:SenderReturns the address that theSenderinstance will sendMessageobjects 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:
addressin interfaceSender- Returns:
- the address that this
Senderis sending to. - Throws:
ClientException- if an error occurs while obtaining theSenderaddress.
-
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:
connectionin interfaceSender- Returns:
- the
Connectioninstance that holds this session'sSender
-
session
public ClientSession session()
-
openFuture
public ClientFuture<Sender> openFuture()
- Specified by:
openFuturein interfaceSender- Returns:
- a
Futurethat will be completed when the remote opens thisSender.
-
close
public void close()
Description copied from interface:SenderRequests a close of theSenderat 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:SenderRequests a close of theSenderat the remote and waits until the Sender has been fully closed or until the configuredSenderOptions.closeTimeout()is exceeded.- Specified by:
closein interfaceSender- Parameters:
error- TheErrorConditionto transmit to the remote along with the close operation.
-
detach
public void detach()
Description copied from interface:SenderRequests a detach of theSenderat 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:SenderRequests a detach of theSenderat the remote and waits until the Sender has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.- Specified by:
detachin interfaceSender- Parameters:
error- TheErrorConditionto transmit to the remote along with the detach operation.
-
closeAsync
public ClientFuture<Sender> closeAsync()
Description copied from interface:SenderRequests a close of theSenderlink at the remote and returns aFuturethat will be completed once the link has been closed.- Specified by:
closeAsyncin interfaceSender- Returns:
- a
Futurethat will be completed when the remote closes thisSenderlink.
-
closeAsync
public ClientFuture<Sender> closeAsync(ErrorCondition error)
Description copied from interface:SenderRequests a close of theSenderlink at the remote and returns aFuturethat will be completed once the link has been closed.- Specified by:
closeAsyncin interfaceSender- Parameters:
error- TheErrorConditionto transmit to the remote along with the close operation.- Returns:
- a
Futurethat will be completed when the remote closes thisSenderlink.
-
detachAsync
public ClientFuture<Sender> detachAsync()
Description copied from interface:SenderRequests a detach of theSenderlink at the remote and returns aFuturethat will be completed once the link has been detached.- Specified by:
detachAsyncin interfaceSender- Returns:
- a
Futurethat will be completed when the remote detaches thisSenderlink.
-
detachAsync
public ClientFuture<Sender> detachAsync(ErrorCondition error)
Description copied from interface:SenderRequests a detach of theSenderlink at the remote and returns aFuturethat will be completed once the link has been detached.- Specified by:
detachAsyncin interfaceSender- Parameters:
error- TheErrorConditionto transmit to the remote along with the detach operation.- Returns:
- a
Futurethat will be completed when the remote detaches thisSenderlink.
-
properties
public java.util.Map<java.lang.String,java.lang.Object> properties() throws ClientExceptionDescription copied from interface:SenderReturns 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:
propertiesin interfaceSender- Returns:
- any properties provided from the remote once the sender has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theSenderremote properties.
-
offeredCapabilities
public java.lang.String[] offeredCapabilities() throws ClientExceptionDescription copied from interface:SenderReturns 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:
offeredCapabilitiesin interfaceSender- Returns:
- any capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theSenderremote offered capabilities.
-
desiredCapabilities
public java.lang.String[] desiredCapabilities() throws ClientExceptionDescription copied from interface:SenderReturns 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:
desiredCapabilitiesin interfaceSender- Returns:
- any desired capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theSenderremote 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)
-
notClosedOrFailed
protected boolean notClosedOrFailed(ClientFuture<?> request, Sender sender)
-
checkClosedOrFailed
protected void checkClosedOrFailed() throws ClientException- Throws:
ClientException
-
-