Interface IgniteQueue<T>

  • All Superinterfaces:
    AutoCloseable, BlockingQueue<T>, Closeable, Collection<T>, Iterable<T>, Queue<T>

    public interface IgniteQueue<T>
    extends BlockingQueue<T>, Closeable
    This interface provides a rich API for working with distributed queues based on In-Memory Data Grid.

    Overview

    Cache queue provides an access to cache elements using typical queue API. Cache queue also implements Collection interface and provides all methods from collections including Collection.addAll(Collection), Collection.removeAll(Collection), and Collection.retainAll(Collection) methods for bulk operations. Note that all Collection methods in the queue may throw IgniteException in case of failure.

    Bounded vs Unbounded

    Queues can be unbounded or bounded. Bounded queues can have maximum capacity. Queue capacity can be set at creation time and cannot be changed later. Here is an example of how to create bounded LIFO queue with capacity of 1000 items.
     IgniteQueue<String> queue = cache().queue("anyName", LIFO, 1000);
     ...
     queue.add("item");
     
    For bounded queues blocking operations, such as take() or put(Object) are available. These operations will block until queue capacity changes to make the operation possible.

    Collocated vs Non-collocated

    Queue items can be placed on one node or distributed throughout grid nodes (governed by collocated parameter). Non-collocated mode is provided only for partitioned caches. If collocated parameter is true, then all queue items will be collocated on one node, otherwise items will be distributed through all grid nodes. Unless explicitly specified, by default queues are collocated.

    Here is an example of how create unbounded queue in non-collocated mode.

     IgniteQueue<String> queue = cache().queue("anyName", 0 /*unbounded*/, false /*non-collocated*/);
     ...
     queue.add("item");
     

    Creating Cache Queues

    Instances of distributed cache queues can be created by calling the following method on Ignite API:
    See Also:
    Ignite.queue(String, int, org.apache.ignite.configuration.CollectionConfiguration)