Search code examples
ignite

Apache Ignite - Distibuted Queue and Executors


I am planning to use Apache Ignite Distributed Queue.

I am using Ignite with a spring boot application. So, on bootup, I will be adding 20 names in a queue. But, since there are 3 servers in a cluster, the same 20 names gets added 3 times. But, i want to add them only once in the queue.

Ignite ignite = Ignition.ignite();

IgniteQueue<String> queue = ignite.queue(
    "queueName", // Queue name.
    0,          // Queue capacity. 0 for unbounded queue.
    null         // Collection configuration.
);

Distributed executors, will be able to poll from the queue and run the task. Here, the executor is expected to poll, run the task and then add the same name to the queue. Trying to achieve round robin here. Only one executor should be running the same task at any point of time, though there are multiple servers in a cluster.

Any suggestion for this.


Solution

  • You can launch ignite cluster singleton service https://apacheignite.readme.io/docs/cluster-singletons which will fill data to queue. Also you can adding data from coordinator node (oldest node in cluster) ignite.cluster().forOldest().node().isLocal()