Interface Link<L extends Link<L>>
-
- All Superinterfaces:
Endpoint<L>
- All Known Implementing Classes:
ProtonLink
,ProtonReceiver
,ProtonSender
public interface Link<L extends Link<L>> extends Endpoint<L>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description L
creditStateUpdateHandler(EventHandler<L> handler)
Handler for link credit updates that occur after a remoteFlow
arrives.L
detach()
Detach this end of the link.L
detachHandler(EventHandler<L> remoteDetachHandler)
Sets aEventHandler
for when an AMQP Detach frame is received from the remote peer for thisLink
which would have been locally opened previously, the Detach from would have been marked as not having been closed.Connection
getConnection()
int
getCredit()
Get the credit that is currently available or assigned to this link.UnsignedLong
getMaxMessageSize()
Gets the local link max message size.String
getName()
Session
getParent()
Gets the parent of thisEndpoint
which can be itself forConnection
instance.ReceiverSettleMode
getReceiverSettleMode()
Gets the local link receiver settlement mode.UnsignedLong
getRemoteMaxMessageSize()
Gets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.ReceiverSettleMode
getRemoteReceiverSettleMode()
Gets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.SenderSettleMode
getRemoteSenderSettleMode()
Gets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.Source
getRemoteSource()
LinkState
getRemoteState()
<T extends Terminus>
TgetRemoteTarget()
Returns the remote targetTerminus
cast to the given type.Role
getRole()
SenderSettleMode
getSenderSettleMode()
Gets the local link sender settlement mode.Session
getSession()
Source
getSource()
LinkState
getState()
<T extends Terminus>
TgetTarget()
Returns the currently set Target for thisLink
.boolean
isDraining()
Indicates if the link is draining.boolean
isLocallyClosedOrDetached()
Returns true if thisLink
is currently locally detached or locally closed meaning the state returned fromgetState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
.boolean
isLocallyDetached()
Returns true if thisLink
is currently locally detached meaning the state returned fromgetState()
is equal toLinkState.DETACHED
.boolean
isReceiver()
boolean
isRemotelyClosed()
Returns true if thisLink
is currently remotely closed meaning the state returned fromgetRemoteState()
is equal toLinkState.CLOSED
.boolean
isRemotelyClosedOrDetached()
Returns true if thisLink
is currently remotely detached or closed meaning the state returned fromgetRemoteState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
.boolean
isRemotelyDetached()
Returns true if thisLink
is currently remotely detached meaning the state returned fromgetRemoteState()
is equal toLinkState.DETACHED
.boolean
isRemotelyOpen()
Returns true if thisLink
is currently remotely open meaning the state returned fromgetRemoteState()
is equal toLinkState.ACTIVE
.boolean
isSender()
L
localDetachHandler(EventHandler<L> localDetachHandler)
Sets aEventHandler
for when an this link is detached locally via a call todetach()
This is a convenience event that supplements the normalEndpoint.localCloseHandler(EventHandler)
event point if set.L
parentEndpointClosedHandler(EventHandler<L> handler)
L
setMaxMessageSize(UnsignedLong maxMessageSize)
Sets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session.L
setReceiverSettleMode(ReceiverSettleMode receiverSettleMode)
Sets the receiver settle mode.L
setSenderSettleMode(SenderSettleMode senderSettleMode)
Sets the sender settle mode.L
setSource(Source source)
L
setTarget(Target target)
L
setTarget(Coordinator coordinator)
Sets theCoordinator
target to assign to the local end of thisLink
.-
Methods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
close, closeHandler, engineShutdownHandler, getAttachments, getCondition, getDesiredCapabilities, getEngine, getLinkedResource, getLinkedResource, getOfferedCapabilities, getProperties, getRemoteCondition, getRemoteDesiredCapabilities, getRemoteOfferedCapabilities, getRemoteProperties, isLocallyClosed, isLocallyOpen, localCloseHandler, localOpenHandler, open, openHandler, setCondition, setDesiredCapabilities, setLinkedResource, setOfferedCapabilities, setProperties
-
-
-
-
Method Detail
-
detach
L detach()
Detach this end of the link.- Returns:
- this Link.
- Throws:
EngineStateException
- if an error occurs detaching theLink
or the Engine is shutdown.
-
isLocallyDetached
boolean isLocallyDetached()
Returns true if thisLink
is currently locally detached meaning the state returned fromgetState()
is equal toLinkState.DETACHED
. A link is locally detached after a call todetach()
.- Returns:
- true if the link is locally closed.
- See Also:
Endpoint.isLocallyOpen()
,Endpoint.isLocallyClosed()
-
isLocallyClosedOrDetached
boolean isLocallyClosedOrDetached()
Returns true if thisLink
is currently locally detached or locally closed meaning the state returned fromgetState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
. A link is locally detached after a call todetach()
and is locally closed after a call toEndpoint.close()
.- Returns:
- true if the link is locally closed or detached.
- See Also:
Endpoint.isLocallyOpen()
,isLocallyDetached()
,Endpoint.isLocallyClosed()
-
getState
LinkState getState()
- Returns:
- the local link state
-
getCredit
int getCredit()
Get the credit that is currently available or assigned to this link.- Returns:
- the current link credit.
-
isDraining
boolean isDraining()
Indicates if the link is draining. For aSender
link this indicates that the remote has requested that the Sender transmit deliveries up to the currently available credit or indicate that it has no more to send. For aReceiver
this indicates that the Receiver has requested that the Sender consume its outstanding credit.- Returns:
- true if the
Link
is currently marked as draining.
-
isSender
boolean isSender()
- Returns:
- true if this link is acting in a sender
Role
.
-
isReceiver
boolean isReceiver()
- Returns:
- true if this link is acting in a receiver
Role
.
-
getConnection
Connection getConnection()
- Returns:
- the parent
Connection
for theLink
-
getParent
Session getParent()
Description copied from interface:Endpoint
Gets the parent of thisEndpoint
which can be itself forConnection
instance.
-
setSenderSettleMode
L setSenderSettleMode(SenderSettleMode senderSettleMode) throws IllegalStateException
Sets the sender settle mode.Should only be called during link set-up, i.e. before calling
Endpoint.open()
. If this endpoint is the initiator of the link, this method can be used to set a value other than the default.If this endpoint is not the initiator, this method should be used to set a local value. According to the AMQP spec, the application may choose to accept the sender's suggestion (accessed by calling
getRemoteSenderSettleMode()
) or choose another value. The value has no effect on Proton, but may be useful to the application at a later point.In order to be AMQP compliant the application is responsible for honoring the settlement mode. See
Link
.- Parameters:
senderSettleMode
- TheSenderSettleMode
that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
getSenderSettleMode
SenderSettleMode getSenderSettleMode()
Gets the local link sender settlement mode.- Returns:
- the local sender settlement mode, or null if none was set.
- See Also:
setSenderSettleMode(SenderSettleMode)
-
setReceiverSettleMode
L setReceiverSettleMode(ReceiverSettleMode receiverSettleMode) throws IllegalStateException
Sets the receiver settle mode.Should only be called during link set-up, i.e. before calling
Endpoint.open()
. If this endpoint is the initiator of the link, this method can be used to set a value other than the default. Used in analogous way tosetSenderSettleMode(SenderSettleMode)
- Parameters:
receiverSettleMode
- TheReceiverSettleMode
that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
getReceiverSettleMode
ReceiverSettleMode getReceiverSettleMode()
Gets the local link receiver settlement mode.- Returns:
- the local receiver settlement mode, or null if none was set.
- See Also:
setReceiverSettleMode(ReceiverSettleMode)
-
setSource
L setSource(Source source) throws IllegalStateException
Sets theSource
to assign to the local end of thisLink
.Must be called during link setup, i.e. before calling the
Endpoint.open()
method.- Parameters:
source
- TheSource
that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
setTarget
L setTarget(Target target) throws IllegalStateException
Sets theTarget
to assign to the local end of thisLink
. Must be called during link setup, i.e. before calling theEndpoint.open()
method.- Parameters:
target
- TheTarget
that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
setTarget
L setTarget(Coordinator coordinator) throws IllegalStateException
Sets theCoordinator
target to assign to the local end of thisLink
.Must be called during link setup, i.e. before calling the
Endpoint.open()
method.- Parameters:
coordinator
- TheCoordinator
target that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
getTarget
<T extends Terminus> T getTarget()
Returns the currently set Target for thisLink
. A link target can be either aTarget
type for aSender
orReceiver
link or if the link is to be transaction resource then the target type will be aCoordinator
instance.- Type Parameters:
T
- The terminus type that the target should be cast to on return.- Returns:
- the link target
Terminus
for the local end of this link.
-
setMaxMessageSize
L setMaxMessageSize(UnsignedLong maxMessageSize) throws IllegalStateException
Sets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session. Null or 0 means no limit.Must be called during link setup, i.e. before calling the
Endpoint.open()
method.- Parameters:
maxMessageSize
- the local max message size value, or null to clear. 0 also means no limit.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
getMaxMessageSize
UnsignedLong getMaxMessageSize()
Gets the local link max message size.- Returns:
- the local max message size, or null if none was set. 0 also means no limit.
- See Also:
setMaxMessageSize(UnsignedLong)
-
isRemotelyOpen
boolean isRemotelyOpen()
Returns true if thisLink
is currently remotely open meaning the state returned fromgetRemoteState()
is equal toLinkState.ACTIVE
. A link is remotely opened after anAttach
has been received from the remote and before aDetach
has been received from the remote.- Specified by:
isRemotelyOpen
in interfaceEndpoint<L extends Link<L>>
- Returns:
- true if the link is remotely open.
- See Also:
isRemotelyClosed()
,isRemotelyDetached()
-
isRemotelyClosed
boolean isRemotelyClosed()
Returns true if thisLink
is currently remotely closed meaning the state returned fromgetRemoteState()
is equal toLinkState.CLOSED
. A link is remotely closed after anDetach
has been received from the remote with the close flag equal to true.- Specified by:
isRemotelyClosed
in interfaceEndpoint<L extends Link<L>>
- Returns:
- true if the link is remotely closed.
- See Also:
isRemotelyOpen()
,isRemotelyDetached()
-
isRemotelyDetached
boolean isRemotelyDetached()
Returns true if thisLink
is currently remotely detached meaning the state returned fromgetRemoteState()
is equal toLinkState.DETACHED
. A link is remotely detached after anDetach
has been received from the remote with the close flag equal to false.- Returns:
- true if the link is remotely detached.
- See Also:
isRemotelyOpen()
,isRemotelyClosed()
-
isRemotelyClosedOrDetached
boolean isRemotelyClosedOrDetached()
Returns true if thisLink
is currently remotely detached or closed meaning the state returned fromgetRemoteState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
. A link is remotely detached or closed after aDetach
has been received from the remote.- Returns:
- true if the link is remotely detached or closed.
- See Also:
isRemotelyOpen()
,isRemotelyClosed()
,isRemotelyDetached()
-
getRemoteSource
Source getRemoteSource()
- Returns:
- the source
Terminus
for the remote end of this link.
-
getRemoteTarget
<T extends Terminus> T getRemoteTarget()
Returns the remote targetTerminus
cast to the given type. This can be used when the underlying type is known by the caller or as a control to validate the assumption of the underlying type.the currently set Target for this
Link
. A link target can be either aTarget
type for aSender
orReceiver
link or if the link is to be transaction resource then the target type will be aCoordinator
instance.
-
getRemoteSenderSettleMode
SenderSettleMode getRemoteSenderSettleMode()
Gets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Returns:
- the sender settlement mode conveyed by the peer, or null if there was none.
- See Also:
setSenderSettleMode(SenderSettleMode)
-
getRemoteReceiverSettleMode
ReceiverSettleMode getRemoteReceiverSettleMode()
Gets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Returns:
- the sender receiver mode conveyed by the peer, or null if there was none.
- See Also:
setReceiverSettleMode(ReceiverSettleMode)
-
getRemoteMaxMessageSize
UnsignedLong getRemoteMaxMessageSize()
Gets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.- Returns:
- the remote max message size conveyed by the peer, or null if none was set. 0 also means no limit.
-
getRemoteState
LinkState getRemoteState()
- Returns:
- the remote link state (as last communicated)
-
localDetachHandler
L localDetachHandler(EventHandler<L> localDetachHandler)
Sets aEventHandler
for when an this link is detached locally via a call todetach()
This is a convenience event that supplements the normalEndpoint.localCloseHandler(EventHandler)
event point if set. If no local detached event handler is set the endpoint will route the detached event to the local closed event handler if set and allow it to process the event in one location.Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.
- Parameters:
localDetachHandler
- TheEventHandler
to notify when this link is locally detached.- Returns:
- the link for chaining.
-
detachHandler
L detachHandler(EventHandler<L> remoteDetachHandler)
Sets aEventHandler
for when an AMQP Detach frame is received from the remote peer for thisLink
which would have been locally opened previously, the Detach from would have been marked as not having been closed.This is a convenience event that supplements the normal
Endpoint.closeHandler(EventHandler)
event point if set. If no detached event handler is set the endpoint will route the detached event to the closed event handler if set and allow it to process the event in one location.- Parameters:
remoteDetachHandler
- TheEventHandler
to notify when this link is remotely closed.- Returns:
- the
Link
for chaining.
-
creditStateUpdateHandler
L creditStateUpdateHandler(EventHandler<L> handler)
Handler for link credit updates that occur after a remoteFlow
arrives.- Parameters:
handler
- An event handler that will be signaled when the link credit is updated by a remote flow.- Returns:
- the
Link
for chaining.
-
parentEndpointClosedHandler
L parentEndpointClosedHandler(EventHandler<L> handler)
Sets aEventHandler
for when the parentSession
orConnection
of this link is locally closed.Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.
- Parameters:
handler
- TheEventHandler
to notify when this link's parent Session is locally closed.- Returns:
- the link for chaining.
-
-