public final class ConcurrentMessagingUtils extends Object
TimeoutException. The timeout used when throwing an exception depends
on the method invoked, the ConcurrentMessagingUtils configuration and the
command invoked.
If a method that takes a timeout is invoked, that timeout is used, otherwise
a cascade approach is used to determine the timeout among the following:
setDefaultTimeout
method.Command that is invokedCommandAck when the invoked
Command is accepted| Constructor and Description |
|---|
ConcurrentMessagingUtils(AgentMessagingLayer agentMessagingLayer)
ConsurrentMessagingUtils constructor.
|
ConcurrentMessagingUtils(AgentMessagingLayer agentMessagingLayer,
Duration defaultTimeout)
Build a ConsurrentMessagingUtils object with a default timeout.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
getAckForCommand(CommandRequest command,
Duration timeout)
Send a CommandRequest on the buses and synchronously wait for the Ack to
come back within the provided Duration timeout.
|
Duration |
getDefaultTimeout()
Get the default timeout for this ConcurrentMessagingUtils object.
|
Future<Object> |
sendAsynchronousCommand(CommandRequest command)
Send a command on the buses and immediately return a Future that will
asynchronously listen for the command reply.
|
Object |
sendSynchronousCommand(CommandRequest command)
Send synchronously a command on the Buses without a timeout.
|
Object |
sendSynchronousCommand(CommandRequest command,
Duration timeout)
Send a command on the Buses and wait for the reply within the provided
Duration timeout.
|
void |
setDefaultTimeout(Duration defaultTimeout)
Set the default timeout for this ConcurrentMessagingUtils object.
|
Future<StatusMessage> |
startListeningForStatusBusMessage(Predicate<BusMessage<? extends Serializable,?>> f)
Get a Future on a StatusBusMessage.
|
Future<StatusMessage> |
startListeningForStatusBusMessage(Predicate<BusMessage<? extends Serializable,?>> filter,
Duration timeout)
Get a Future on a StatusBusMessage.
|
public ConcurrentMessagingUtils(AgentMessagingLayer agentMessagingLayer)
agentMessagingLayer - The AgentMessagingLayer used to send messages on the buses.public ConcurrentMessagingUtils(AgentMessagingLayer agentMessagingLayer, Duration defaultTimeout)
agentMessagingLayer - The AgentMessagingLayer used to send messages on the buses.defaultTimeout - The default timeout used when synchronous commands are invoked.public void setDefaultTimeout(Duration defaultTimeout)
defaultTimeout - The default timeout.public Duration getDefaultTimeout()
public Object sendSynchronousCommand(CommandRequest command) throws Exception
Command annotationCommandAckcommand - The CommandRequest object to be sent on the buses.Exception - If an exception was fired by the remote execution of the
command or the timeout expired or no valid timeout could
be found.public Object sendSynchronousCommand(CommandRequest command, Duration timeout) throws Exception
command - The CommandRequest object to be sent on the buses.timeout - The Duration timeout. If the reply is not received within
the timeout a TimeoutException will be thrown.Exception - If an exception was fired by the remote execution of the
command or the timeout expired.public Future<Object> sendAsynchronousCommand(CommandRequest command)
command - The CommandRequest object to be sent on the buses.public Object getAckForCommand(CommandRequest command, Duration timeout) throws Exception
command - The CommandRequest object to be sent on the buses.timeout - Duration timeout. If the CommandAck is not received within the
timeout a TimeoutException will be thrown.Exception - If an exception was fired by the remote execution of the
command or the timeout expired.public Future<StatusMessage> startListeningForStatusBusMessage(Predicate<BusMessage<? extends Serializable,?>> filter, Duration timeout)
filter - ScriptingStatusBusMessageFilter The message filtertimeout - Duration timeout, after which a
ScriptiongTimeoutException is thrown. This timeout is from the
time the method is invoked. If this timeout is reached an
exception will be thrown if/when the Future is exercised.public Future<StatusMessage> startListeningForStatusBusMessage(Predicate<BusMessage<? extends Serializable,?>> f)
f - ScriptingStatusBusMessageFilter The message filterCopyright © 2016 LSST. All rights reserved.