Interface MessageSender


  • public interface MessageSender

    Interface used by a resource adaptor entity to send messages to other Rhino nodes, within the context of the resource adaptor entity.

    Instances of this interface are obtained from the MessageFacility.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void sendBroadcast​(byte[] payload)
      Sends the given message asynchronously to the same resource adaptor entity on all nodes in the cluster, including the sending node.
      void sendMessage​(int destinationNode, byte[] payload)
      Send the given message asynchronously to the same resource adaptor entity on the specified destination node.
      void sendMessage​(String destinationNode, byte[] payload)
      Send the given message asynchronously to the same resource adaptor entity on the specified destination node.
      RemoteResult<?>[] sendRequest​(byte[] payload, boolean synchronous)
      Send the given request to the same resource adaptor entity on all nodes in the cluster, including the sending node.
      RemoteResult<?> sendRequest​(int destinationNode, byte[] payload, boolean synchronous)
      Send the given request to the same resource adaptor entity on the specified destination node.
      RemoteResult<?> sendRequest​(String destinationNode, byte[] payload, boolean synchronous)
      Sends the given request to the same resource adaptor entity on the specified destination node.
    • Method Detail

      • sendMessage

        void sendMessage​(int destinationNode,
                         byte[] payload)
                  throws IOException

        Send the given message asynchronously to the same resource adaptor entity on the specified destination node.

        For new work, it is recommended to use sendMessage(String, byte[]) instead of this method, where that method uses string node IDs instead of numeric.

        Parameters:
        destinationNode - the destination node.
        payload - the message.
        Throws:
        IOException - if an error occurs trying to send the request.
      • sendBroadcast

        void sendBroadcast​(byte[] payload)
                    throws UnsupportedOperationException,
                           IOException

        Sends the given message asynchronously to the same resource adaptor entity on all nodes in the cluster, including the sending node.

        Broadcasts are not supported when using the pool clustering mode. This method will throw an UnsupportedOperationException if the node is currently configured as a pool node.

        Parameters:
        payload - the message.
        Throws:
        UnsupportedOperationException - if the node is configured to use the pool clustering mode.
        IOException - if an error occurs trying to send the request.
      • sendRequest

        RemoteResult<?> sendRequest​(int destinationNode,
                                    byte[] payload,
                                    boolean synchronous)
                             throws IOException

        Send the given request to the same resource adaptor entity on the specified destination node.

        For new work, it is recommended to use sendRequest(String, byte[], boolean) instead of this method, where that method uses string node IDs instead of numeric.

        Parameters:
        destinationNode - the destination node.
        payload - the request message.
        synchronous - flag indicating whether the request should be sent synchronously (true) or asynchronously (false). A synchronous request will only return control to the calling thread once a result has been received from the destination node.
        Returns:
        the result.
        Throws:
        IOException - if an error occurs trying to send the request.
      • sendRequest

        RemoteResult<?>[] sendRequest​(byte[] payload,
                                      boolean synchronous)
                               throws UnsupportedOperationException,
                                      IOException

        Send the given request to the same resource adaptor entity on all nodes in the cluster, including the sending node.

        Broadcasts are not supported when using the pool clustering mode. This method will throw an UnsupportedOperationException if the node is currently configured as a pool node.

        Parameters:
        payload - the request message.
        synchronous - flag indicating whether the request should be sent synchronously (true) or asynchronously (false). A synchronous request will only return control to the calling thread when results have been received from all nodes.
        Returns:
        an array of result objects, one for each node.
        Throws:
        UnsupportedOperationException - if the node is configured to use the pool clustering mode.
        IOException - if an error occurs trying to send the request.
      • sendMessage

        void sendMessage​(String destinationNode,
                         byte[] payload)
                  throws IOException

        Send the given message asynchronously to the same resource adaptor entity on the specified destination node.

        This is a newer version of the send operation that uses a java.lang.String representation for the node ID instead of int.

        Parameters:
        destinationNode - the destination node.
        payload - the message.
        Throws:
        IOException - if an error occurs trying to send the request.
        Since:
        Rhino 3.2
      • sendRequest

        RemoteResult<?> sendRequest​(String destinationNode,
                                    byte[] payload,
                                    boolean synchronous)
                             throws IOException

        Sends the given request to the same resource adaptor entity on the specified destination node.

        This is a newer version of the send operation that uses a java.lang.String representation for the node ID instead of int.

        Parameters:
        destinationNode - the destination node.
        payload - the request message.
        synchronous - flag indicating whether the request should be sent synchronously (true) or asynchronously (false). A synchronous request will only return control to the calling thread once a result has been received from the destination node.
        Returns:
        the result.
        Throws:
        IOException - if an error occurs trying to send the request.
        Since:
        Rhino 3.2