org.apache.ignite.internal

## Class IgniteMessagingImpl

- java.lang.Object
- - org.apache.ignite.internal.AsyncSupportAdapter<IgniteMessaging>
  - - org.apache.ignite.internal.IgniteMessagingImpl

All Implemented Interfaces:
  Externalizable, Serializable, IgniteMessaging, IgniteAsyncSupport

    public class IgniteMessagingImpl
    extends AsyncSupportAdapter<IgniteMessaging>
    implements IgniteMessaging, Externalizable

`IgniteMessaging` implementation.

See Also:
  Serialized Form

### Field Summary

### Fields inherited from class org.apache.ignite.internal.AsyncSupportAdapter

`curFut`

### Constructor Summary

Constructors
Constructor and Description
`IgniteMessagingImpl()` Required by `Externalizable`.
`IgniteMessagingImpl(GridKernalContext ctx, ClusterGroupAdapter prj, boolean async)`

### Method Summary

All Methods Instance Methods Concrete Methods
`ClusterGroup` `clusterGroup()` Gets the cluster group to which this `GridMessaging` instance belongs.
`protected IgniteMessaging` `createAsyncInstance()` Creates component with asynchronous mode enabled.
`void` `localListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)` Adds local listener for given topic on local node only.
`void` `readExternal(ObjectInput in)`
`protected Object` `readResolve()` Reconstructs object on unmarshalling.
`UUID` `remoteListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)` Adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well).
`IgniteFuture<UUID>` `remoteListenAsync(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)` Asynchronously adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well).
`void` `send(@Nullable Object topic, Collection<?> msgs)` Sends given messages with the specified topic to the nodes in the underlying cluster group.
`void` `send(@Nullable Object topic, Object msg)` Sends given message with specified topic to the nodes in the underlying cluster group.
`void` `sendOrdered(@Nullable Object topic, Object msg, long timeout)` Sends given message with specified topic to the nodes in the underlying cluster group.
`void` `stopLocalListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)` Unregisters local listener for given topic on local node only.
`void` `stopRemoteListen(UUID opId)` Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
`IgniteFuture<Void>` `stopRemoteListenAsync(UUID opId)` Asynchronously unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
`void` `writeExternal(ObjectOutput out)`

### Methods inherited from class org.apache.ignite.internal.AsyncSupportAdapter

`createFuture, future, future, isAsync, saveOrGet, withAsync`

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

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

### Methods inherited from interface org.apache.ignite.IgniteMessaging

`withAsync`

### Methods inherited from interface org.apache.ignite.lang.IgniteAsyncSupport

`future, isAsync`

### Constructor Detail

#### IgniteMessagingImpl

    public IgniteMessagingImpl()

Required by `Externalizable`.

#### IgniteMessagingImpl

    public IgniteMessagingImpl(GridKernalContext ctx,
                               ClusterGroupAdapter prj,
                               boolean async)

Parameters:
  `ctx` - Kernal context.
  `prj` - Projection.
  `async` - Async support flag.

### Method Detail

#### clusterGroup

    public ClusterGroup clusterGroup()

Gets the cluster group to which this `GridMessaging` instance belongs.

Specified by:
  `clusterGroup` in interface `IgniteMessaging`
Returns:
  Cluster group to which this `GridMessaging` instance belongs.

#### send

    public void send(@Nullable
                     @Nullable Object topic,
                     Object msg)

Sends given message with specified topic to the nodes in the underlying cluster group.

By default all local listeners will be executed in the calling thread, or if you use `IgniteMessaging.withAsync()`, listeners will execute in public thread pool (in this case it is user's responsibility to implement back-pressure and limit number of concurrently executed async messages).

Specified by:
  `send` in interface `IgniteMessaging`
Parameters:
  `topic` - Topic to send to, `null` for default topic.
  `msg` - Message to send.

#### send

    public void send(@Nullable
                     @Nullable Object topic,
                     Collection<?> msgs)

Sends given messages with the specified topic to the nodes in the underlying cluster group.

By default all local listeners will be executed in the calling thread, or if you use `IgniteMessaging.withAsync()`, listeners will execute in public thread pool (in this case it is user's responsibility to implement back-pressure and limit number of concurrently executed async messages).

Specified by:
  `send` in interface `IgniteMessaging`
Parameters:
  `topic` - 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.

#### sendOrdered

    public void sendOrdered(@Nullable
                            @Nullable Object topic,
                            Object msg,
                            long timeout)

Sends given message with specified topic to the nodes in the underlying cluster group. Messages sent with this method will arrive in the same order they were sent. Note that if a topic is used for ordered messages, then it cannot be reused for non-ordered messages. Note that local listeners are always executed in public thread pool, no matter default or `IgniteMessaging.withAsync()` mode is used.

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.

Specified by:
  `sendOrdered` in interface `IgniteMessaging`
Parameters:
  `topic` - Topic to send to, `null` for default topic.
  `msg` - Message to send.
  `timeout` - Message timeout in milliseconds, `0` for default which is `IgniteConfiguration.getNetworkTimeout()`.

#### localListen

    public void localListen(@Nullable
                            @Nullable Object topic,
                            IgniteBiPredicate<UUID,?> p)

Adds local listener for given topic on local node only. This listener will be notified whenever any node within the cluster group will send a message for a given topic to this node. Local listen subscription will happen regardless of whether local node belongs to this cluster group or not.

Specified by:
  `localListen` in interface `IgniteMessaging`
Parameters:
  `topic` - 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.

#### stopLocalListen

    public void stopLocalListen(@Nullable
                                @Nullable Object topic,
                                IgniteBiPredicate<UUID,?> p)

Unregisters local listener for given topic on local node only.

Specified by:
  `stopLocalListen` in interface `IgniteMessaging`
Parameters:
  `topic` - Topic to unsubscribe from.
  `p` - Listener predicate.

#### remoteListen

    public UUID remoteListen(@Nullable
                             @Nullable Object topic,
                             IgniteBiPredicate<UUID,?> p)

Adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well). This means that any node within this cluster group can send a message for a given topic and all nodes within the cluster group will receive listener notifications.

Specified by:
  `remoteListen` in interface `IgniteMessaging`
Parameters:
  `topic` - 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.
Returns:
  `Operation ID` that can be passed to `IgniteMessaging.stopRemoteListen(UUID)` method to stop listening.

#### remoteListenAsync

    public IgniteFuture<UUID> remoteListenAsync(@Nullable
                                                @Nullable Object topic,
                                                IgniteBiPredicate<UUID,?> p)
                                         throws IgniteException

Asynchronously adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well). This means that any node within this cluster group can send a message for a given topic and all nodes within the cluster group will receive listener notifications.

Specified by:
  `remoteListenAsync` in interface `IgniteMessaging`
Parameters:
  `topic` - 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.
Returns:
  a Future representing pending completion of the operation. The completed future contains `Operation ID` that can be passed to `IgniteMessaging.stopRemoteListen(UUID)` method to stop listening.
Throws:
  `IgniteException` - If failed to add listener.

#### stopRemoteListen

    public void stopRemoteListen(UUID opId)

Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `stopRemoteListen` in interface `IgniteMessaging`
Parameters:
  `opId` - Listen ID that was returned from `IgniteMessaging.remoteListen(Object, IgniteBiPredicate)` method.

#### stopRemoteListenAsync

    public IgniteFuture<Void> stopRemoteListenAsync(UUID opId)
                                             throws IgniteException

Asynchronously unregisters all listeners identified with provided operation ID on all nodes in the cluster group.

Specified by:
  `stopRemoteListenAsync` in interface `IgniteMessaging`
Parameters:
  `opId` - Listen ID that was returned from `IgniteMessaging.remoteListen(Object, IgniteBiPredicate)` method.
Returns:
  a Future representing pending completion of the operation.
Throws:
  `IgniteException` - If failed to unregister listeners.

#### createAsyncInstance

    protected IgniteMessaging createAsyncInstance()

Creates component with asynchronous mode enabled.

Overrides:
  `createAsyncInstance` in class `AsyncSupportAdapter<IgniteMessaging>`
Returns:
  Component with asynchronous mode enabled.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### readResolve

    protected Object readResolve()
                          throws ObjectStreamException

Reconstructs object on unmarshalling.

Returns:
  Reconstructed object.
Throws:
  `ObjectStreamException` - Thrown in case of unmarshalling error.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020