public class GridMessagingImpl extends Object implements GridMessaging
GridMessaging implementation.| Constructor and Description |
|---|
GridMessagingImpl(GridKernalContext ctx,
GridProjection prj) |
| Modifier and Type | Method and Description |
|---|---|
void |
localListen(Object topic,
GridBiPredicate<UUID,?> p)
Adds local listener for given topic on local node only.
|
GridProjection |
projection()
Gets grid projection to which this
GridMessaging instance belongs. |
GridFuture<UUID> |
remoteListen(Object topic,
GridBiPredicate<UUID,?> p)
Adds a message listener for a given topic to all nodes in the projection (possibly including
this node if it belongs to the projection as well).
|
void |
send(Object topic,
Collection<?> msgs)
Sends given messages with specified topic to the nodes in this projection.
|
void |
send(Object topic,
Object msg)
Sends given message with specified topic to the nodes in this projection.
|
void |
sendOrdered(Object topic,
Object msg,
long timeout)
Sends given message with specified topic to the nodes in this projection.
|
void |
stopLocalListen(Object topic,
GridBiPredicate<UUID,?> p)
Unregisters local listener for given topic on local node only.
|
GridFuture<?> |
stopRemoteListen(UUID opId)
Unregisters all listeners identified with provided operation ID on all nodes in this projection.
|
public GridMessagingImpl(GridKernalContext ctx, GridProjection prj)
ctx - Kernal context.prj - Projection.public GridProjection projection()
GridMessaging instance belongs.projection in interface GridMessagingGridMessaging instance belongs.public void send(@Nullable Object topic, Object msg) throws GridException
send in interface GridMessagingtopic - Topic to send to, null for default topic.msg - Message to send.GridException - If failed to send a message to any of the nodes.GridEmptyProjectionException - Thrown in case when this projection is empty.public void send(@Nullable Object topic, Collection<?> msgs) throws GridException
send in interface GridMessagingtopic - Topic to send to, null for default topic.msgs - Messages to send. Order of the sending is undefined. If the method produces
the exception none or some messages could have been sent already.GridException - If failed to send a message to any of the nodes.GridEmptyProjectionException - Thrown in case when this projection is empty.public void sendOrdered(@Nullable Object topic, Object msg, long timeout) throws GridException
The timeout parameter specifies how long an out-of-order message will stay in a queue,
waiting for messages that are ordered ahead of it to arrive. If timeout expires, then all ordered
messages that have not arrived before this message will be skipped. When (and if) expired messages
actually do arrive, they will be ignored.
sendOrdered in interface GridMessagingtopic - Topic to send to, null for default topic.msg - Message to send.timeout - Message timeout in milliseconds, 0 for default
which is GridConfiguration.getNetworkTimeout().GridException - If failed to send a message to any of the nodes.GridEmptyProjectionException - Thrown in case when this projection is empty.public void localListen(@Nullable Object topic, GridBiPredicate<UUID,?> p)
localListen in interface GridMessagingtopic - Topic to subscribe to.p - Predicate that is called on each received message. If predicate returns false,
then it will be unsubscribed from any further notifications.public void stopLocalListen(@Nullable Object topic, GridBiPredicate<UUID,?> p)
stopLocalListen in interface GridMessagingtopic - Topic to unsubscribe from.p - Listener predicate.public GridFuture<UUID> remoteListen(@Nullable Object topic, GridBiPredicate<UUID,?> p)
remoteListen in interface GridMessagingtopic - Topic to subscribe to, null means default topic.p - Predicate that is called on each node for each received message. If predicate returns false,
then it will be unsubscribed from any further notifications.operation ID
that can be passed to GridMessaging.stopRemoteListen(UUID) method to stop listening.public GridFuture<?> stopRemoteListen(UUID opId)
stopRemoteListen in interface GridMessagingopId - Listen ID that was returned from GridMessaging.remoteListen(Object, GridBiPredicate) method.Copyright © 2014. All rights reserved.