public abstract class MessagingListenActor<T> extends Object implements IgniteBiPredicate<UUID,T>
IgniteMessaging.localListen(Object, IgniteBiPredicate)
method.Constructor and Description |
---|
MessagingListenActor() |
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
and
protected final Ignite ignite()
public final boolean apply(UUID nodeId, T rcvMsg)
apply
in interface IgniteBiPredicate<UUID,T>
nodeId
- First parameter.rcvMsg
- Second parameter.protected void onError(Throwable e)
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()
.
e
- Exception thrown from method receive(UUID, Object)
.protected abstract void receive(UUID nodeId, T rcvMsg) throws Throwable
respond
, stop
or skip
methods. Note that if none of these methods are called - listener will continue
listen for the new messages.nodeId
- ID of the sender node.rcvMsg
- Received message.Throwable
- Thrown in case of any errors. Method onError(Throwable)
} will
be called right before returning from this method.protected final void stop()
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.
protected final void stop(@Nullable @Nullable Object respMsg) throws IgniteException
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.
respMsg
- Optional response message. If not null
- it will be sent to the original
sender node.IgniteException
- Thrown in case of any errors.protected final void skip()
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.
protected final void respond(@Nullable @Nullable Object respMsg) throws IgniteException
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.
respMsg
- Optional response message. If not null
- it will be sent to the original
sender node.IgniteException
- Thrown in case of any errors.protected final void respond(UUID id, @Nullable @Nullable Object respMsg) throws IgniteException
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.
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.IgniteException
- Thrown in case of any errors.
GridGain In-Memory Computing Platform : ver. 8.9.19 Release Date : April 10 2025