CommunicationPointConnection defines the interface for communication point connections used by Rhapsody. Connections are returned by CommunicationPoint implementations and are responsible for actually sending and receiving messages over their specific communication channel.
There is no configure(Configuration)
method in this interface. Any required configuration of a connection should be done by the parent CommunicationPoint when the connection is created.
There are a number of important conventions to be aware of when implementing a communication point connection:
- It is expected that when a
ConnectionException
is thrown from any method, for any reason, that the state of the connection is set to ERROR and any other communication threads using the connection will throw a ConnectionFailedException the next time they attempt to use the connection. If this is not done it is possible (with a bidirectional comm point) to have a communication thread left running, with no way to stop it, and this makes the communication point impossible to stop. - It is expected that a connection will either be a
PollingInputConnection
with an effective implementation of thePollingInputConnection.isInputAvailable()
method or has areceiveMessage(Message)
method that blocks until a message is available or some time-out has occurred. It is possible to write an implementation that does not implement thePollingInputConnection
interface and wherereceiveMessage(Message)
immediately returns false if no message is available. Such an implementation will work correctly but will result in a busy loop (with the engine constantly callingreceiveMessage(Message)
) which will impact negatively on the performance of the Rhapsody server.
CommunicationPointConnection States
Enum class State:
-
UNCONNECTED
- there is no connection yet -
CONNECTED
- It is currently connected. -
CLOSED
- Connection is closed. -
ERROR
- Error happened in the connection.
Method | Description |
---|---|
|
Retrieves the identifier that identifies this connection. Should be unique amongst all connections from the same communication point, and must not change over the lifetime of the connection. |
dropConnection() |
Drops this connection if the connection is able to be dropped and later re-established. Will be called by the engine if the connection is doing output only, an idle time-out is specified and no message has been sent from the connection in that amount of time. If this connection is able to disconnect and reconnect at a later time then this method should disconnect and set the connections state to UNCONNECTED . |
|
Reconnects this connection if required. Will be called by the engine if Exceptions:
|
|
Gets the state of this connection. Must return one of: |
|
Cleans up after the connection has finished being used. |
|
Signal to finish any communication taking place as soon as possible. Basically used to interrupt blocked receives. |
|
Gets a message from the connection. Must write any incoming message data to the body of the message. Returns true if a full message was successfully received, or false otherwise. Properties may also be set on the Message. Parameters:
Exceptions:
|
|
Notifies connection that the last received message has been received by the engine. Allows the connection to mark the message as processed so it is received again if successfully received, or to queue it again for receipt if it was not received. Parameters:
Exceptions:
|
|
Sends a message over the connection. Should throw a Parameters:
Exceptions:
A A |
|
Initialises a connection to send a number of messages. Called immediately before multiple calls to Exceptions:
|
finishSend() |
Cleans up a connection after sending a number of messages. Called immediately after multiple calls to Note that Rhapsody regards a message as sent when Exceptions:
|