Skip to main content
Version: 5.16

Configuring Queues

Hazelcast distributed queue is an implementation of java.util.concurrent.BlockingQueue. Being distributed, Hazelcast distributed queue enables all cluster members to interact with it. Using Hazelcast distributed queue, you can add an item in one cluster member and remove it from another one. You can create and configure queue using the Queue custom resource.

Configuring a Queue Resource​

You can use any of the following configuration options in the Queue resource. For more information, see the API Reference.

FieldDescription
nameName of the queue configuration that you're creating. If empty, the custom resource (CR) name is used.
hazelcastResourceNameDefines the name of the Hazelcast resource for which the queue configuration is created.
backupCountCount of synchronous backups.
asyncBackupCountCount of asynchronous backups.
maxSizeMax size of the queue.
emptyQueueTTLSecondsTime in seconds after which the Queue will be destroyed if it stays empty or unused. If the values is not provided the Queue will never be destroyed.
priorityComparatorClassNameThe name of the comparator class. If the class name is provided, the Queue becomes Priority Queue.

Example Configuration​

The following Queue custom resource creates a queue configuration for the Hazelcast custom resource that is defined in the hazelcastResourceName field.

Example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Queue
metadata:
name: queue-sample
spec:
hazelcastResourceName: hazelcast
backupCount: 1
asyncBackupCount: 0
emptyQueueTTLSeconds: -1
maxSize: 0
priorityComparatorClassName: "com.hazelcast.collection.impl.queue.model.PriorityElementComparator"

After creating the Queue resource, use the following command to check its status:

shell
kubectl get queue queue-sample -o wide
NAME STATUS HAZELCAST-RESOURCE MESSAGE
queue-sample Success hazelcast