Interface MessagingChannel<T>

    • Method Detail

      • newSend

        Send<T> newSend​(T message)
        Creates a new Send operation.

        Send operation doesn't assume any response to be received from the destination node. If request-response type of communication is required then consider using the newRequest(Object) method.

        By default, this operation will not wait for the message to be processed on the receiver side. It is possible to change this behavior via Send.withAckMode(AckMode) method.

        Parameters:
        message - Message to be sent.
        Returns:
        New operation.
        See Also:
        Send.submit()
      • newRequest

        Request<T> newRequest​(T request)
        Creates a new Request operation.
        Parameters:
        request - Request.
        Returns:
        New operation.
        See Also:
        Request.submit()
      • newBroadcast

        Broadcast<T> newBroadcast​(T request)
        Creates a new Broadcast operation.

        By default, this operation will not wait for the message to be processed on the receiver side. It is possible to change this behavior via Broadcast.withAckMode(AckMode) method.

        Parameters:
        request - Message to broadcast.
        Returns:
        New operation.
        See Also:
        Broadcast.submit()
      • id

        MessagingChannelId id()
        Returns the universally unique identifier of this channel.
        Returns:
        Universally unique identifier of this channel.
      • baseType

        Class<T> baseType()
        Returns the base type of messages that can be transferred through this channel.
        Returns:
        Base type of messages that can be transferred through this channel.
        See Also:
        MessagingChannelConfig(Class)
      • nioThreads

        int nioThreads()
        Returns the size of a thread pool for handling NIO-based socket connections (see MessagingConfigBase.setNioThreads(int)).
        Returns:
        Size of a thread pool for handling NIO-based socket connections.
      • cluster

        ClusterView cluster()
        Returns the cluster view of this channel.

        The returned cluster view contains only those nodes that have a receiver and do match the channel's filtering criteria.

        Returns:
        Cluster view.
      • withCluster

        MessagingChannel<T> withCluster​(ClusterView cluster)
        Returns a copy of this channel that will use the specified cluster view and will inherit all other options from this instance.
        Parameters:
        cluster - Cluster view.
        Returns:
        Channel wrapper.
      • sendAsync

        default SendFuture sendAsync​(T msg)
        Asynchronously sends the specified message with a mandatory acknowledgement.
        Parameters:
        msg - Message.
        Returns:
        Future object to be completed after receiving an acknowledgement.
      • sendAsync

        default SendFuture sendAsync​(T msg,
                                     AckMode ackMode)
        Asynchronously sends the specified message with the specified acknowledgement mode.
        Parameters:
        msg - Message.
        ackMode - Acknowledgement mode.
        Returns:
        Operation future.
      • sendAsync

        default SendFuture sendAsync​(Object affinityKey,
                                     T msg)
        Asynchronously sends the specified message with a mandatory acknowledgement.
        Parameters:
        affinityKey - Affinity key (see Send.withAffinity(Object)).
        msg - Message.
        Returns:
        Future object to be completed after receiving an acknowledgement.
      • sendAsync

        default SendFuture sendAsync​(Object affinityKey,
                                     T msg,
                                     AckMode ackMode)
        Asynchronously sends the specified message with the specified acknowledgement mode.
        Parameters:
        affinityKey - Affinity key (see Send.withAffinity(Object)).
        msg - Message.
        ackMode - Acknowledgement mode.
        Returns:
        Operation future.
      • send

        default void send​(T msg)
                   throws HekateException
        Synchronously sends the specified message and awaits for an acknowledgement.
        Parameters:
        msg - Message.
        Throws:
        HekateException - If operation failed.
      • send

        default void send​(T msg,
                          AckMode ackMode)
                   throws HekateException
        Synchronously sends the specified message with the specified acknowledgement mode.
        Parameters:
        msg - Message.
        ackMode - Acknowledgement mode.
        Throws:
        HekateException - If operation failed.
      • send

        default void send​(Object affinityKey,
                          T msg,
                          AckMode ackMode)
                   throws HekateException
        Synchronously sends the specified message with the specified acknowledgement mode.
        Parameters:
        affinityKey - Affinity key (see Send.withAffinity(Object)).
        msg - Message.
        ackMode - Acknowledgement mode.
        Throws:
        HekateException - If operation failed.
      • requestAsync

        default RequestFuture<T> requestAsync​(T msg)
        Asynchronously sends the specified request.
        Parameters:
        msg - Request message.
        Returns:
        Future object to be completed after receiving a response.
      • requestAsync

        default RequestFuture<T> requestAsync​(Object affinityKey,
                                              T msg)
        Asynchronously sends the specified request.
        Parameters:
        affinityKey - Affinity key (see Request.withAffinity(Object)).
        msg - Request message.
        Returns:
        Future object to be completed after receiving a response.
      • request

        default T request​(T msg)
                   throws HekateException
        Synchronously sends the specified request and awaits for a response.
        Parameters:
        msg - Request message.
        Returns:
        Response.
        Throws:
        HekateException - If operation failed.
      • subscribeAsync

        default SubscribeFuture<T> subscribeAsync​(T msg,
                                                  SubscribeCallback<T> callback)
        Asynchronously sends the specified subscription request.
        Parameters:
        msg - Subscription request message.
        callback - Subscription callback.
        Returns:
        Future object to be completed after receiving the final response (see ResponsePart.isLastPart()).
      • subscribe

        default List<T> subscribe​(T msg)
                           throws HekateException
        Synchronously sends the specified subscription request and accumulates all responses.

        Notice: This method blocks until the final response is received (see ResponsePart.isLastPart()) and accumulates all intermediate parts in memory.

        Parameters:
        msg - Subscription request message.
        Returns:
        All response parts that were received.
        Throws:
        HekateException - If operation failed.
      • subscribe

        default List<T> subscribe​(Object affinityKey,
                                  T msg)
                           throws HekateException
        Synchronously sends the specified subscription request and accumulates all responses.

        Notice: This method blocks until the final response is received (see ResponsePart.isLastPart()) and accumulates all intermediate parts in memory.

        Parameters:
        affinityKey - Affinity key (see Subscribe.withAffinity(Object)).
        msg - Subscription request message.
        Returns:
        All response parts that were received.
        Throws:
        HekateException - If operation failed.
      • broadcastAsync

        default BroadcastFuture<T> broadcastAsync​(T msg)
        Asynchronously broadcasts the specified message with a mandatory acknowledgement.
        Parameters:
        msg - Message.
        Returns:
        Future object to be completed after receiving acknowledgements from all nodes.
      • broadcastAsync

        default BroadcastFuture<T> broadcastAsync​(T msg,
                                                  AckMode ackMode)
        Asynchronously broadcasts the specified message with the specified acknowledgement mode.
        Parameters:
        msg - Message.
        ackMode - Acknowledgement mode.
        Returns:
        Operation future.
      • broadcastAsync

        default BroadcastFuture<T> broadcastAsync​(Object affinityKey,
                                                  T msg)
        Asynchronously broadcasts the specified message with a mandatory acknowledgement.
        Parameters:
        affinityKey - Affinity key (see Broadcast.withAffinity(Object)).
        msg - Message.
        Returns:
        Future object to be completed after receiving acknowledgements from all nodes.
      • broadcastAsync

        default BroadcastFuture<T> broadcastAsync​(Object affinityKey,
                                                  T msg,
                                                  AckMode ackMode)
        Asynchronously broadcasts the specified message with the specified acknowledgement mode.
        Parameters:
        affinityKey - Affinity key (see Broadcast.withAffinity(Object)).
        msg - Message.
        ackMode - Acknowledgement mode.
        Returns:
        Operation future.
      • broadcast

        default BroadcastResult<T> broadcast​(T msg)
                                      throws HekateException
        Synchronously broadcasts the specified message with a mandatory acknowledgement.
        Parameters:
        msg - Message.
        Returns:
        Broadcast result.
        Throws:
        HekateException - If operation failed.
      • broadcast

        default BroadcastResult<T> broadcast​(T msg,
                                             AckMode ackMode)
                                      throws HekateException
        Synchronously broadcasts the specified message with the specified acknowledgement mode.
        Parameters:
        msg - Message.
        ackMode - Acknowledgement mode.
        Returns:
        Broadcast result.
        Throws:
        HekateException - If operation failed.
      • aggregateAsync

        default AggregateFuture<T> aggregateAsync​(T msg)
        Asynchronously submits the specified aggregation request.
        Parameters:
        msg - Aggregation request message.
        Returns:
        Future object to be completed after receiving responses from all nodes.
      • aggregateAsync

        default AggregateFuture<T> aggregateAsync​(Object affinityKey,
                                                  T msg)
        Asynchronously submits the specified aggregation request.
        Parameters:
        affinityKey - Affinity key (see Aggregate.withAffinity(Object)).
        msg - Aggregation request message.
        Returns:
        Future object to be completed after receiving responses from all nodes.
      • aggregate

        default AggregateResult<T> aggregate​(T msg)
                                      throws HekateException
        Synchronously submits the specified aggregation request.
        Parameters:
        msg - Aggregation request message.
        Returns:
        Aggregation result.
        Throws:
        HekateException - If operation failed.