Apache Ignite.NET Documentation

The Apache Ignite .NET Developer Hub

Welcome to the Apache Ignite .NET developer hub. You'll find comprehensive guides and documentation to help you start working with Apache Ignite.NET as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Topic Based

Exchange custom messages between nodes across the cluster.

Ignite distributed messaging allows for topic based cluster-wide communication between all nodes. Messages with a specified message topic can be distributed to all or sub-group of nodes that have subscribed to that topic.

Ignite messaging is based on publish-subscribe paradigm where publishers and subscribers are connected together by a common topic. When one of the nodes sends a message A for topic T, it is published on all nodes that have subscribed to T.

📘

Any new node joining the cluster automatically gets subscribed to all the topics that other nodes in the cluster (or cluster group) are subscribed to.

Distributed Messaging functionality in Ignite is provided via IMessaging interface. You can get an instance of IMessaging, like so:

IIgnite ignite = Ignition.Start();

// Messaging instance over this cluster.
IMessaging msg = ignite.GetMessaging();

// Messaging instance over given cluster group (in this case, remote nodes).
IMessaging rmtMsg = ignite.GetCluster().ForRemotes().GetMessaging();

Publish Messages

Send methods allow sending/publishing messages with a specified message topic to all nodes. Messages can be sent in ordered or unordered manner.
##Ordered Messages
SendOrdered(...) method can be used if you want to receive messages in the order they were sent. A timeout parameter is passed to specify how long a message will stay in the queue to wait for messages that are supposed to be sent before this message. If the timeout expires, then all the messages that have not yet arrived for a given topic on that node will be ignored.
##Unordered Messages
Send(...) methods do not guarantee message ordering. This means that when you sequentially send message A and message B, you are not guaranteed that the target node first receives A and then B.

Subscribe for Messages

Listen methods help to listen/subscribe for messages. When these methods are called, a listener with specified message topic is registered on all (or sub-group of) nodes to listen for new messages. With listen methods, a predicate is passed that returns a boolean value which tells the listener to continue or stop listening for new messages.
##Local Listen
LocalListen(...) method registers a message listener with specified topic only on the local node and listens for messages from any node in this cluster group.
##Remote Listen
RemoteListen(...) method registers message listeners with specified topic on all nodes in this cluster group and listens for messages from any node in this cluster group .

Example

Following example shows message exchange between remote nodes.

void Messaging()
{
    using (IIgnite ignite = Ignition.Start())
    {
        var rmtMsg = ignite.GetCluster().ForRemotes().GetMessaging();

        // Add listener for messages on all remote nodes.
        rmtMsg.RemoteListen(new Listener(), "myTopic");

        // Send message to remote nodes.
        rmtMsg.Send("Hello!", "myTopic");
    }
}

class Listener : IMessageListener<string>
{
    public bool Invoke(Guid nodeId, string message)
    {
        Console.WriteLine("Received message '{0}' from node '{1}'", message, nodeId);

        return true; // Return true to continue listening.
    }
}

Updated less than a minute ago

Topic Based


Exchange custom messages between nodes across the cluster.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.