org.apache.ignite.messaging

## Class MessagingListenActor<T>

- java.lang.Object
- - org.apache.ignite.messaging.MessagingListenActor<T>

- All Implemented Interfaces:
    Serializable, IgniteBiPredicate<UUID,T>

      public abstract class MessagingListenActor<T>
      extends Object
      implements IgniteBiPredicate<UUID,T>

  Convenience actor-base adapter for `IgniteMessaging.localListen(Object, IgniteBiPredicate)` method.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessagingListenActor()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and 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()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.lang.IgniteBiPredicate

      `and`

- - ### 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.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020