Interface MessagingService


  • public interface MessagingService
    Interface for low level messaging primitives.
    • Method Detail

      • sendAsync

        CompletableFuture<Void> sendAsync​(Endpoint ep,
                                          String type,
                                          byte[] payload)
        Sends a message asynchronously to the specified communication end point. The message is specified using the type and payload.
        Parameters:
        ep - end point to send the message to.
        type - type of message.
        payload - message payload bytes.
        Returns:
        future that is completed when the message is sent
      • sendAndReceive

        default CompletableFuture<byte[]> sendAndReceive​(Endpoint ep,
                                                         String type,
                                                         byte[] payload)
        Sends a message asynchronously and expects a response.
        Parameters:
        ep - end point to send the message to.
        type - type of message.
        payload - message payload.
        Returns:
        a response future
      • sendAndReceive

        default CompletableFuture<byte[]> sendAndReceive​(Endpoint ep,
                                                         String type,
                                                         byte[] payload,
                                                         Executor executor)
        Sends a message synchronously and expects a response.
        Parameters:
        ep - end point to send the message to.
        type - type of message.
        payload - message payload.
        executor - executor over which any follow up actions after completion will be executed.
        Returns:
        a response future
      • sendAndReceive

        default CompletableFuture<byte[]> sendAndReceive​(Endpoint ep,
                                                         String type,
                                                         byte[] payload,
                                                         Duration timeout)
        Sends a message asynchronously and expects a response.
        Parameters:
        ep - end point to send the message to.
        type - type of message.
        payload - message payload.
        timeout - operation timeout
        Returns:
        a response future
      • sendAndReceive

        CompletableFuture<byte[]> sendAndReceive​(Endpoint ep,
                                                 String type,
                                                 byte[] payload,
                                                 Duration timeout,
                                                 Executor executor)
        Sends a message synchronously and expects a response.
        Parameters:
        ep - end point to send the message to.
        type - type of message.
        payload - message payload.
        executor - executor over which any follow up actions after completion will be executed.
        timeout - operation timeout
        Returns:
        a response future
      • registerHandler

        void registerHandler​(String type,
                             BiConsumer<Endpoint,​byte[]> handler,
                             Executor executor)
        Registers a new message handler for message type.
        Parameters:
        type - message type.
        handler - message handler
        executor - executor to use for running message handler logic.
      • registerHandler

        void registerHandler​(String type,
                             BiFunction<Endpoint,​byte[],​byte[]> handler,
                             Executor executor)
        Registers a new message handler for message type.
        Parameters:
        type - message type.
        handler - message handler
        executor - executor to use for running message handler logic.
      • registerHandler

        void registerHandler​(String type,
                             BiFunction<Endpoint,​byte[],​CompletableFuture<byte[]>> handler)
        Registers a new message handler for message type.
        Parameters:
        type - message type.
        handler - message handler
      • unregisterHandler

        void unregisterHandler​(String type)
        Unregister current handler, if one exists for message type.
        Parameters:
        type - message type