Class MessagingListenActor<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean apply​(UUID nodeId, T rcvMsg)
      Predicate body.
      protected Ignite ignite()
      Gets grid instance associated with this actor.
      protected void onError​(Throwable e)
      This method is called in case when method receive(UUID, Object) threw an exception.
      protected abstract void receive​(UUID nodeId, T rcvMsg)
      This method receives the message.
      protected void respond​(@Nullable Object respMsg)
      Responds to the original sender node with given message and continues to listen for the new messages.
      protected void respond​(UUID id, @Nullable Object respMsg)
      Responds to the provided node with given message and continues to listen for the new messages.
      protected void skip()
      Skips current message and continues to listen for new message.
      protected void stop()
      This method instructs underlying implementation to stop receiving new messages and unregister the message listener.
      protected void stop​(@Nullable Object respMsg)
      This method sends the response message to the original sender node and instructs underlying implementation to stop receiving new messages and unregister the message listener.
      String toString()
    • Constructor Detail

      • MessagingListenActor

        public MessagingListenActor()
    • Method Detail

      • ignite

        protected final Ignite ignite()
        Gets grid instance associated with this actor.
        Returns:
        Grid instance associated with this actor.
      • apply

        public final boolean apply​(UUID nodeId,
                                   T rcvMsg)
        Predicate body.
        Specified by:
        apply in interface IgniteBiPredicate<UUID,​T>
        Parameters:
        nodeId - First parameter.
        rcvMsg - Second parameter.
        Returns:
        Return value.
      • onError

        protected void onError​(Throwable e)
        This method is called in case when method receive(UUID, Object) threw an exception. Insides of this method the implementation should call any of the respond, stop or skip methods. If overriding method does nothing - than return value of method receive(UUID, Object) is undefined.

        Default implementation simply calls method stop().

        Parameters:
        e - Exception thrown from method receive(UUID, Object).
      • receive

        protected abstract void receive​(UUID nodeId,
                                        T rcvMsg)
                                 throws Throwable
        This method receives the message. This is the only method that subclass needs to override. Insides of this method the implementation should call any of the respond, stop or skip methods. Note that if none of these methods are called - listener will continue listen for the new messages.
        Parameters:
        nodeId - ID of the sender node.
        rcvMsg - Received message.
        Throws:
        Throwable - Thrown in case of any errors. Method onError(Throwable)} will be called right before returning from this method.
      • stop

        protected final void stop()
        This method instructs underlying implementation to stop receiving new messages and unregister the message listener.

        Note that subclasses can call any of respond, stop or skip methods any number of times. Only the last executed method will determine whether or not the implementation will continue listen for the new messages.

      • stop

        protected final void stop​(@Nullable
                                  @Nullable Object respMsg)
                           throws IgniteException
        This method sends the response message to the original sender node and instructs underlying implementation to stop receiving new messages and unregister the message listener.

        Note that subclasses can call any of respond, stop or skip methods any number of times. Only the last executed method will determine whether or not the implementation will continue listen for the new messages.

        Parameters:
        respMsg - Optional response message. If not null - it will be sent to the original sender node.
        Throws:
        IgniteException - Thrown in case of any errors.
      • skip

        protected final void skip()
        Skips current message and continues to listen for new message. This method simply calls respond(null).

        Note that subclasses can call any of respond, stop or skip methods any number of times. Only the last executed method will determine whether or not the implementation will continue listen for the new messages.

      • respond

        protected final void respond​(@Nullable
                                     @Nullable Object respMsg)
                              throws IgniteException
        Responds to the original sender node with given message and continues to listen for the new messages.

        Note that subclasses can call any of respond, stop or skip methods any number of times. Only the last executed method will determine whether or not the implementation will continue listen for the new messages.

        Parameters:
        respMsg - Optional response message. If not null - it will be sent to the original sender node.
        Throws:
        IgniteException - Thrown in case of any errors.
      • respond

        protected final void respond​(UUID id,
                                     @Nullable
                                     @Nullable Object respMsg)
                              throws IgniteException
        Responds to the provided node with given message and continues to listen for the new messages.

        Note that subclasses can call any of respond, stop or skip methods any number of times. Only the last executed method will determine whether or not the implementation will continue listen for the new messages.

        Parameters:
        id - ID of the node to send the message to, if any.
        respMsg - Optional response message. If not null - it will be sent to the original sender node.
        Throws:
        IgniteException - Thrown in case of any errors.