Introduction

I hope everyone is doing well. Today we are going to look at the topic called NATS queue mechanism. It is a lightweight and high-performance messaging system that acts as a distributed messaging queue. In the current digital era, we try to de-couple applications from one another, so it is supposed to adapt to plug it in another version or another application easily.

What is NATS JetStream, and what makes us consider this?

NATS, or the "NATS Messaging System," is an open-source messaging system designed for simplicity, performance, and scalability. It was originally developed in the Go programming language (hence the name GNATS, which stands for Golang NATS), but it now has client libraries for various programming languages, making it versatile and accessible for developers working in different ecosystems. NATS has an active open-source community, providing support, documentation, and a range of client libraries for different programming languages.

Use Case for NATS and NATS Jetstream

Nats

NATS JetStream is an extension of NATS core which is designed for use cases that require additional features such as guaranteed message delivery, durability, and persistence.

Features of NATS JetStream

Comparison between other Message Queue Platforms

Queuing System NATS jetstream Rabbit MQ Kafka SQS
Open Source yes yes yes no
Message replay yes no yes

no

No built-in capability. However, we can do this using DQL and other options

Event Streaming yes no yes no
Message/event ordering based Sequence # Order # Partition message grouping/message group Id
Setup Complexity Easy Easy Complex Easy
Delivery guarantee (exactly once) It uses acknowledgments to acknowledge the receipt of a message It supports a feature called publisher confirms. enable.idempotence = true using MessageDeduplicationId concept
Scheduled and delayed delivery yes yes

Kafka, by default, does not provide native support for delayed message delivery.

using these options, we can implement the same

Message Timestamp

Topic Partitions

Intermediate Topic

yes
Horizontally scalable yes no yes yes
Cloud Availability yes yes yes yes
On-Premises yes yes yes no
Filters

subject filter

wildcard pattern

routing mechanism

wildcard pattern

topics and partition filter and route messages based on attributes


NATS Topology

NATS Topology

Persistence Layer options

The storage mechanism used by NATS JetStream can vary based on the configuration. JetStream supports different storage backends, and you can configure it to use either file-based storage or other storage solutions like SQL databases.

Implementation steps of NATS Jetstream

Let's look at the implementation steps in another article.

Conclusion

If you require features like guaranteed delivery and persistence, especially in scenarios where messages need to be retained over time, NATS JetStream would be a more suitable choice. I hope you enjoy reading this article.