@FunctionalInterface public interface MessageHandler<T,U>
This is a functional interface for handling messages on a Connection instance.
Message handlers are registered for specific types. When
handle(Object) is invoked by a Connection, the handler
must return a valid CompletableFuture to be completed with the message reply.
Note that input and output for the message handler must be serializable via the configured Serializer
instance. This means it must implement Serializable, Externalizable, or
CatalystSerializable or provide a custom TypeSerializer.
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<U> |
handle(T message)
Handles a message.
|
CompletableFuture<U> handle(T message)
The handler must synchronously return a CompletableFuture to be completed with the
message response. If the message is handled synchronously, return CompletableFuture.completedFuture(Object)
to immediately complete the returned future. Otherwise, create a CompletableFuture
and call CompletableFuture.complete(Object) or
CompletableFuture.completeExceptionally(Throwable) to complete the future with a reply
or error respectively.
message - The message to handle.Copyright © 2013–2015. All rights reserved.