Class MessageDemux
- java.lang.Object
-
- de.aristaflow.ilm.core.runtimeservice.MessageDemux
-
public class MessageDemux extends Object
This class extends theLocalExecutionMessageNotifier
by the means to notify listeners without a reply and get this reply via another route. For instance, SSE does not allow to send data, so the execution message is just notified and the reply is expected via the normal reply method of the (remote) runtime environment. Internally this reply will then be forwarded to the corresponding notifier awaiting the reply synchronously.
-
-
Field Summary
Fields Modifier and Type Field Description protected LocalExecutionMessageNotifier
lemn
The wrapped message notifier.protected Map<String,Map<Long,CompletableFuture<ReplyMessage<?>>>>
waiting
The futures awaited by server notifications indexed by session ID and message ID.
-
Constructor Summary
Constructors Constructor Description MessageDemux(LocalExecutionMessageNotifier lemn)
Creates a new execution message notifier handling listeners via the designated notifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URI[]
getUris()
Gets the URIs of the correspondingLocalExecutionMessageNotifier
which is needed to register the listener when starting or resuming via the runtime service.URI[]
registerListener(SessionToken session, String sessionId, ExecutionMessageNotification emn)
Future<ReplyMessage<?>>
registerNotification(String sessionId, long messageId)
Registers a notification for the designated session and message ID and returns the corresponding future providing the reply message.boolean
reply(ReplyMessage<?> reply)
Replies to an execution message with the designated reply.void
unregisterListener(SessionToken session, String sessionId, ExecutionMessageNotification emn)
-
-
-
Field Detail
-
lemn
protected final LocalExecutionMessageNotifier lemn
The wrapped message notifier.
-
waiting
protected final Map<String,Map<Long,CompletableFuture<ReplyMessage<?>>>> waiting
The futures awaited by server notifications indexed by session ID and message ID.
-
-
Constructor Detail
-
MessageDemux
public MessageDemux(LocalExecutionMessageNotifier lemn)
Creates a new execution message notifier handling listeners via the designated notifier.- Parameters:
lemn
- The notifier for forwarding execution messages for synchronous dispatching to the correspondingExecutionMessageNotification
.
-
-
Method Detail
-
registerNotification
public Future<ReplyMessage<?>> registerNotification(String sessionId, long messageId)
Registers a notification for the designated session and message ID and returns the corresponding future providing the reply message.- Parameters:
sessionId
- The ID of the execution session for which to forward a message to the listener.messageId
- The ID of the execution messages which to forward to the listener.- Returns:
- A future for retrieving the reply message to the corresponding execution message.
-
reply
public boolean reply(ReplyMessage<?> reply)
Replies to an execution message with the designated reply. This will set the reply in the corresponding future thus signalling the corresponding notifiers waiting for the reply.- Parameters:
reply
- the reply for an execution message sent by a notifier.- Returns:
- Whether the designated reply has been successfully set in the corresponding future.
-
getUris
public URI[] getUris()
Gets the URIs of the correspondingLocalExecutionMessageNotifier
which is needed to register the listener when starting or resuming via the runtime service.- Returns:
- The URIs of the corresponding
LocalExecutionMessageNotifier
. - See Also:
ADEPT2Service.getURIs()
-
registerListener
public URI[] registerListener(SessionToken session, String sessionId, ExecutionMessageNotification emn)
-
unregisterListener
public void unregisterListener(SessionToken session, String sessionId, ExecutionMessageNotification emn)
-
-