public interface Session extends LowLevelSession
Modifier and Type | Method and Description |
---|---|
void |
addSessionListener(SessionListener listener)
Add a new instance into the list of objects which will be notified
of session events.
|
boolean |
addSessionListener(SessionListener listener,
boolean check)
Add a new instance into the list of objects which will be notified
of session events.
|
java.lang.Object |
echo(java.io.Serializable obj,
int timeout,
RoutingKey key)
Send an echo request message using provided data as a message payload
and wait for reply.
|
void |
forward(Message message)
Send provided message as an asynchronous request without waiting for a
reply.
|
void |
registerSynchronizer(StateSynchronizer sync)
Sets the instance of the state synchronizer the reader and writer
threads should use, if and only if there is no other state synchronizer
already in use.
|
void |
removeSessionListener(SessionListener listener)
Remove the listener from the list of objects to be notified about
session events.
|
void |
terminate()
Terminate the network session.
|
java.lang.Object |
transact(Message message,
int timeout)
Send provided message as a synchronous request and wait for reply.
|
getException, getNodeAddress, getRemoteAddress, isRunning
void addSessionListener(SessionListener listener)
listener
- The listener to add.boolean addSessionListener(SessionListener listener, boolean check)
If the check
flag is set, then it ensure that the session is still connected
before adding the listener. If the session is not connected, then the listener will not
be added and this will return false
.
listener
- The listener to add.check
- Flag to check session state before adding.true
if the listener was added. false
otherwise.void removeSessionListener(SessionListener listener)
listener
- The listener to remove.void registerSynchronizer(StateSynchronizer sync)
sync
- The synchronizer to register or null
if the
currently registered synchronizer should be deregistered.void forward(Message message)
REQUEST_ASYNCH
.message
- Request message.java.lang.Object transact(Message message, int timeout) throws java.lang.Exception
The message passed as a parameter must be completely filled with all required information - routing key should point to valid entry point. If addresses in the routing key are not set then destination is assumed at directly connected node and appropriate addresses are assigned automatically.
Caller can specify timeout for waiting reply message. If timeout is set to 0 then queue will wait for reply as long as queue is running.
message
- Request message.timeout
- Reply wait timeout.java.lang.Exception
- Is thrown if reply received from remote side has an exception
as its payload, if a timeout occurs before the reply message
is received or if a problem occurs during transmission.void terminate()
java.lang.Object echo(java.io.Serializable obj, int timeout, RoutingKey key) throws ProtocolViolation, java.lang.InterruptedException, RequestTimeoutException, java.lang.Exception
If instance of RoutingKey
is provided then message is
sent to node pointed by the RoutingKey
. Otherwise
directly connected node is assumed. Note that processing of the ECHO
message ignores entry point information in RoutingKey
so
an instance of RoutingKey created with default constructor can
be used.
Caller can specify timeout for waiting reply message. If this is not necessary then 0 should be passed as If timeout is set to 0 then queue will wait for reply as long as queue is running.
obj
- Message payload.timeout
- Reply wait timeout.key
- The destination node address information.java.lang.InterruptedException
- forwarded from transactImpl()RequestTimeoutException
- forwarded from transactImpl()ProtocolViolation
- in case of protocol errors.java.lang.Exception
- Is thrown if a timeout occurs before the reply message
is received or if a problem occurs during transmission.