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 forIgniteMessaging.localListen(Object, IgniteBiPredicate)
method.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MessagingListenActor()
-
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 methodreceive(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
-
-
-
-
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 interfaceIgniteBiPredicate<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 methodreceive(UUID, Object)
threw an exception. Insides of this method the implementation should call any of therespond
,stop
orskip
methods. If overriding method does nothing - than return value of methodreceive(UUID, Object)
is undefined.Default implementation simply calls method
stop()
.- Parameters:
e
- Exception thrown from methodreceive(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 therespond
,stop
orskip
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. MethodonError(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
orskip
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
orskip
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 notnull
- 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 callsrespond(null)
.Note that subclasses can call any of
respond
,stop
orskip
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
orskip
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 notnull
- 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
orskip
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 notnull
- it will be sent to the original sender node.- Throws:
IgniteException
- Thrown in case of any errors.
-
-