In-Memory Data Grid Messaging
Hazelcast is the leading open source in-memory data grid. It provides key in-memory data grid messaging capabilities behind very simple APIs. Hazelcast provides multiple approaches to achieve distributed in-memory data grid messaging.
Distributed Queue (IQueue)
Hazelcast Distributed Queue allows an application to produce and consume messages at different speeds. Hazelcast IQueue is built on top of java.util.concurrent.BlockingQueue and it allows threads from all the Java Virtual Machines (JVM) that are connected to the cluster to interact with the queue: items can be added in one JVM and removed in another.
The key advantages of Hazelcast Distributed Queues are:
- Hazelcast Distributed Queues have guaranteed ordering of the delivery of the messages. IQueue preserves ordering of the messages so the messages are taken from the queue in the same order they were put on the queue.
- They have controlled message management. With capacity controlled queues, an application can have producers and consumers working at different speeds: for example, producers producing faster/slower than consumers.
- They have full synchronous backup of Hazelcast Queue with the ability of multi-node backup.
- They have persistence. Hazelcast allows you to load and store the distributed queue items from/to a persistent datastore using the interface QueueStore. If queue store is enabled, each item added to the queue will also be stored at the configured queue store and subsequently can be loaded from the store if the item is not available in IQueue.
An application can register a message onto a Topic, which will then be distributed to all instances of the application that have subscribed to that Topic. Hazelcast internally uses IQueue (Distributed Hazelcast Queue) to publish the message on a Topic. The default size of the queue is 1 million, but the size is configurable.
Some of the most important benefits of Hazelcast Topics are:
- Hazelcast Topic is highly scalable to many nodes without requiring downtime, thus increasing throughput.
- It has no single-point-of-failure, which is not easy to achieve with pure Java Message Service (JMS) solutions.
- It is a capable product delivering millions of messages scalability in business critical applications at many reputed organizations such as Ericsson and NTT of Japan.
- It has flexible memory management.
- It has zero overhead – no metadata is created or tagged along with the original message.
- It has message ordering. Hazelcast provides certain ordering guarantees on the delivery of messages: for example, if a cluster member publishes a sequence of messages, then Hazelcast will guarantee that each of the other nodes in the cluster that have subscribed to the topic will receive these messages in the same order.
Hazelcast In-memory Management over JMS
Some of the key benefits of using Hazelcast In-Memory Messaging over JMS are:
- Hazelcast In-memory Management (IMM) has ultra low latency and high throughput for sending and receiving messages due to data being stored in memory instead of fetching data from a disk-bound RDBMS.
- It has in-memory high-availability. There is no need to write complex code to persist messages on a disk bound store as is done in JMS; Hazelcast guarantees the availability of messages.
- Its distributed messaging adds to the flexibility of adding or removing messages or data items from any node in the cluster and messages or data items received by any listener node in the cluster. This further translates to not requiring to pre-configure source and destination nodes for a messaging application.
- For Hazelcast IMM, scaling out a Hazelcast cluster is simple and straightforward. It does not require downtime.
- Unlike JMS configurations, which are highly vendor specific, the Hazelcast IMM platform is built with the conventional JDK nomenclature and on a similar paradigm: any developer/engineer who is familiar with JDK’s standard APIs should feel at home while using Hazelcast.
The diagram below depicts a typical IMM architecture with Hazelcast in Embedded mode:
And in client-server mode:
Products in this Use Case: