Class ProtonSession
- java.lang.Object
-
- org.apache.qpid.protonj2.engine.impl.ProtonEndpoint<Session>
-
- org.apache.qpid.protonj2.engine.impl.ProtonSession
-
-
Field Summary
-
Fields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine
-
-
Constructor Summary
Constructors Constructor Description ProtonSession(ProtonConnection connection, int localChannel)Creates a newProtonSessioninstance bound to the givenProtonConnection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtonSessionclose()Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.TransactionControllercoordinator(java.lang.String name)Create a newTransactionControllerusing the provided name.ProtonConnectiongetConnection()Symbol[]getDesiredCapabilities()longgetHandleMax()intgetIncomingCapacity()intgetLocalChannel()Symbol[]getOfferedCapabilities()intgetOutgoingCapacity()ProtonConnectiongetParent()Gets the parent of thisEndpointwhich can be itself forConnectioninstance.java.util.Map<Symbol,java.lang.Object>getProperties()intgetRemainingIncomingCapacity()intgetRemainingOutgoingCapacity()intgetRemoteChannel()Symbol[]getRemoteDesiredCapabilities()Symbol[]getRemoteOfferedCapabilities()java.util.Map<Symbol,java.lang.Object>getRemoteProperties()SessionStategetRemoteState()SessionStategetState()booleanisLocallyClosed()Returns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.booleanisLocallyOpen()Returns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.booleanisRemotelyClosed()booleanisRemotelyOpen()java.util.Set<Link<?>>links()ProtonSessionopen()Open the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed.ProtonReceiverreceiver(java.lang.String name)Create a newReceiverlink using the provided nameProtonSessionreceiverOpenHandler(EventHandler<Receiver> remoteReceiverOpenEventHandler)Sets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a receiving link.java.util.Set<ProtonReceiver>receivers()ProtonSendersender(java.lang.String name)Create a newSenderlink using the provided name.ProtonSessionsenderOpenHandler(EventHandler<Sender> remoteSenderOpenEventHandler)Sets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a sending link.java.util.Set<ProtonSender>senders()ProtonSessionsetDesiredCapabilities(Symbol... capabilities)Sets the capabilities that are desired from the remote when thisEndpointis opened.SessionsetHandleMax(long handleMax)Set the handle max value for this Session.SessionsetIncomingCapacity(int incomingCapacity)Sets the maximum number of bytes this session can be sent from the remote.ProtonSessionsetOfferedCapabilities(Symbol... capabilities)Sets the capabilities to be offered on to the remote when thisEndpointis opened.SessionsetOutgoingCapacity(int outgoingCapacity)Sets the maximum number of bytes this session can be write before blocking additional sends until the written bytes are known to have been flushed to the write.ProtonSessionsetProperties(java.util.Map<Symbol,java.lang.Object> properties)Sets the properties to be sent to the remote when thisEndpointis Opened.ProtonSessiontransactionManagerOpenHandler(EventHandler<TransactionManager> remoteTxnManagerOpenEventHandler)Sets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a transaction coordination link.-
Methods inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResource
-
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.engine.Endpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResource
-
-
-
-
Constructor Detail
-
ProtonSession
public ProtonSession(ProtonConnection connection, int localChannel)
Creates a newProtonSessioninstance bound to the givenProtonConnection.- Parameters:
connection- The connection that is the parent of the session instance.localChannel- The local channel onto which this session is bound.
-
-
Method Detail
-
getConnection
public ProtonConnection getConnection()
- Specified by:
getConnectionin interfaceSession- Returns:
- the parent
Connectionfor this Session.
-
getParent
public ProtonConnection getParent()
Description copied from interface:EndpointGets the parent of thisEndpointwhich can be itself forConnectioninstance.
-
getLocalChannel
public int getLocalChannel()
- Returns:
- the local channel onto which this
Sessionis bound.
-
getRemoteChannel
public int getRemoteChannel()
- Returns:
- the remote channel onto which this
Sessionis bound or -1 if not yet remotely opened.
-
getState
public SessionState getState()
-
getRemoteState
public SessionState getRemoteState()
- Specified by:
getRemoteStatein interfaceSession- Returns:
- the remote session state (as last communicated)
-
open
public ProtonSession open() throws java.lang.IllegalStateException, EngineStateException
Description copied from interface:EndpointOpen the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives.- Specified by:
openin interfaceEndpoint<Session>- Returns:
- this
Endpointinstance. - Throws:
EngineStateException- if an error occurs opening the Connection or the Engine is shutdown.java.lang.IllegalStateException
-
close
public ProtonSession close() throws EngineFailedException
Description copied from interface:EndpointClose the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it. If the engine encounters an error writing the performative or the engine is in a failed state from a previous error then this method will throw an exception. If the engine has been shutdown then this method will close out the local end of theEndpointand clean up any local resources before returning normally.- Specified by:
closein interfaceEndpoint<Session>- Returns:
- this
Endpointinstance. - Throws:
EngineFailedException- if an error occurs closing the end point or the Engine is in a failed state.
-
isLocallyOpen
public boolean isLocallyOpen()
Description copied from interface:EndpointReturns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.- Specified by:
isLocallyOpenin interfaceEndpoint<Session>- Returns:
trueif theEndpointis locally open.- See Also:
Endpoint.isLocallyClosed()
-
isLocallyClosed
public boolean isLocallyClosed()
Description copied from interface:EndpointReturns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.- Specified by:
isLocallyClosedin interfaceEndpoint<Session>- Returns:
trueif theEndpointis locally closed.- See Also:
Endpoint.isLocallyOpen()
-
setIncomingCapacity
public Session setIncomingCapacity(int incomingCapacity)
Description copied from interface:SessionSets the maximum number of bytes this session can be sent from the remote.- Specified by:
setIncomingCapacityin interfaceSession- Parameters:
incomingCapacity- maximum number of incoming bytes this session will allow- Returns:
- this
Sessioninstance.
-
getIncomingCapacity
public int getIncomingCapacity()
- Specified by:
getIncomingCapacityin interfaceSession- Returns:
- the current incoming capacity of this session.
-
getRemainingIncomingCapacity
public int getRemainingIncomingCapacity()
- Specified by:
getRemainingIncomingCapacityin interfaceSession- Returns:
- the remaining session capacity based on how many bytes are currently pending,
-
setOutgoingCapacity
public Session setOutgoingCapacity(int outgoingCapacity)
Description copied from interface:SessionSets the maximum number of bytes this session can be write before blocking additional sends until the written bytes are known to have been flushed to the write. This limit is intended to deal with issues of memory allocation when the I/O layer allows for asynchronous writes and finer grained control over the pending write buffers is needed.- Specified by:
setOutgoingCapacityin interfaceSession- Parameters:
outgoingCapacity- maximum number of outgoing bytes this session will allow before stopping senders from sending.- Returns:
- this
Sessioninstance.
-
getOutgoingCapacity
public int getOutgoingCapacity()
- Specified by:
getOutgoingCapacityin interfaceSession- Returns:
- the current outgoing capacity limit of this session.
-
getRemainingOutgoingCapacity
public int getRemainingOutgoingCapacity()
- Specified by:
getRemainingOutgoingCapacityin interfaceSession- Returns:
- the remaining session outgoing capacity based on how many bytes are currently pending,
-
setHandleMax
public Session setHandleMax(long handleMax) throws java.lang.IllegalStateException
Description copied from interface:SessionSet the handle max value for this Session. The handle max value can only be modified prior to a call toEndpoint.open(), once the session has been opened locally an error will be thrown if this method is called.- Specified by:
setHandleMaxin interfaceSession- Parameters:
handleMax- The value to set for handle max when opening the session.- Returns:
- this
Sessioninstance. - Throws:
java.lang.IllegalStateException- if the Session has already been opened.
-
getHandleMax
public long getHandleMax()
- Specified by:
getHandleMaxin interfaceSession- Returns:
- the currently configured handle max for this
Session
-
setProperties
public ProtonSession setProperties(java.util.Map<Symbol,java.lang.Object> properties)
Description copied from interface:EndpointSets the properties to be sent to the remote when thisEndpointis Opened. TheEndpointproperties value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setPropertiesin interfaceEndpoint<Session>- Parameters:
properties- The properties that will be sent to the remote when this Connection is opened.- Returns:
- this
Endpointinstance.
-
getProperties
public java.util.Map<Symbol,java.lang.Object> getProperties()
- Specified by:
getPropertiesin interfaceEndpoint<Session>- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setOfferedCapabilities
public ProtonSession setOfferedCapabilities(Symbol... capabilities)
Description copied from interface:EndpointSets the capabilities to be offered on to the remote when thisEndpointis opened. The offered capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setOfferedCapabilitiesin interfaceEndpoint<Session>- Parameters:
capabilities- The capabilities to be offered to the remote when theEndpointis opened.- Returns:
- this
Endpointinstance.
-
getOfferedCapabilities
public Symbol[] getOfferedCapabilities()
- Specified by:
getOfferedCapabilitiesin interfaceEndpoint<Session>- Returns:
- the configured capabilities that are offered to the remote when the
Endpointis opened.
-
setDesiredCapabilities
public ProtonSession setDesiredCapabilities(Symbol... capabilities)
Description copied from interface:EndpointSets the capabilities that are desired from the remote when thisEndpointis opened. The desired capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setDesiredCapabilitiesin interfaceEndpoint<Session>- Parameters:
capabilities- The capabilities desired from the remote when theEndpointis opened.- Returns:
- this
Endpointinstance.
-
getDesiredCapabilities
public Symbol[] getDesiredCapabilities()
- Specified by:
getDesiredCapabilitiesin interfaceEndpoint<Session>- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
-
senders
public java.util.Set<ProtonSender> senders()
Description copied from interface:Session
-
receivers
public java.util.Set<ProtonReceiver> receivers()
Description copied from interface:Session
-
isRemotelyOpen
public boolean isRemotelyOpen()
Description copied from interface:EndpointReturns true if thisEndpointis currently remotely open meaning that the AMQP performative that completes the open phase of thisEndpoint's lifetime has arrived but the performative that closes it has not.- Specified by:
isRemotelyOpenin interfaceEndpoint<Session>- Returns:
trueif theEndpointis remotely open.- See Also:
Endpoint.isRemotelyClosed()
-
isRemotelyClosed
public boolean isRemotelyClosed()
Description copied from interface:EndpointReturns true if thisEndpointis currently remotely closed meaning that the AMQP performative that completes the close phase of thisEndpoint's lifetime has arrived.- Specified by:
isRemotelyClosedin interfaceEndpoint<Session>- Returns:
trueif theEndpointis remotely closed.- See Also:
Endpoint.isRemotelyOpen()
-
getRemoteOfferedCapabilities
public Symbol[] getRemoteOfferedCapabilities()
- Specified by:
getRemoteOfferedCapabilitiesin interfaceEndpoint<Session>- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint.
-
getRemoteDesiredCapabilities
public Symbol[] getRemoteDesiredCapabilities()
- Specified by:
getRemoteDesiredCapabilitiesin interfaceEndpoint<Session>- Returns:
- the capabilities desired by the remote when it opened its end of the
Endpoint.
-
getRemoteProperties
public java.util.Map<Symbol,java.lang.Object> getRemoteProperties()
- Specified by:
getRemotePropertiesin interfaceEndpoint<Session>- Returns:
- the properties sent by the remote when it opened its end of the
Endpoint.
-
sender
public ProtonSender sender(java.lang.String name)
Description copied from interface:SessionCreate a newSenderlink using the provided name.
-
receiver
public ProtonReceiver receiver(java.lang.String name)
Description copied from interface:SessionCreate a newReceiverlink using the provided name
-
coordinator
public TransactionController coordinator(java.lang.String name) throws java.lang.IllegalStateException
Description copied from interface:SessionCreate a newTransactionControllerusing the provided name.- Specified by:
coordinatorin interfaceSession- Parameters:
name- The name to assign to the createdTransactionController- Returns:
- a newly created
TransactionControllerinstance. - Throws:
java.lang.IllegalStateException- if theSessionhas already been closed.
-
senderOpenHandler
public ProtonSession senderOpenHandler(EventHandler<Sender> remoteSenderOpenEventHandler)
Description copied from interface:SessionSets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a sending link. Used to process remotely initiated sending link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote Receiver creation. If an event handler for remote sender open is registered on this Session for a link scoped to it then this handler will be invoked instead of the variant in the Connection API.- Specified by:
senderOpenHandlerin interfaceSession- Parameters:
remoteSenderOpenEventHandler- the EventHandler that will be signaled when a sender link is remotely opened.- Returns:
- this session for chaining
-
receiverOpenHandler
public ProtonSession receiverOpenHandler(EventHandler<Receiver> remoteReceiverOpenEventHandler)
Description copied from interface:SessionSets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a receiving link. Used to process remotely initiated receiving link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote Sender creation. If an event handler for remote sender open is registered on this Session for a link scoped to it then this handler will be invoked instead of the variant in the Connection API.- Specified by:
receiverOpenHandlerin interfaceSession- Parameters:
remoteReceiverOpenEventHandler- the EventHandler that will be signaled when a receiver link is remotely opened.- Returns:
- this session for chaining
-
transactionManagerOpenHandler
public ProtonSession transactionManagerOpenHandler(EventHandler<TransactionManager> remoteTxnManagerOpenEventHandler)
Description copied from interface:SessionSets aEventHandlerfor when an AMQP Attach frame is received from the remote peer for a transaction coordination link. Used to process remotely initiated transaction manager link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remoteTransactionControllercreation. If an event handler for remoteTransactionControlleropen is registered on this Session for aTransactionControllerscoped to it then this handler will be invoked instead of the variant in theConnectionAPI.- Specified by:
transactionManagerOpenHandlerin interfaceSession- Parameters:
remoteTxnManagerOpenEventHandler- the EventHandler that will be signaled when aTransactionControllerlink is remotely opened.- Returns:
- this session for chaining
-
-