Class IgniteMessagingImpl

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