NATS Blog

Welcome to the NATS Blog! We have content from NATS Maintainers, end-users, and community contributors. We always appreciate outside contributions so if you would like to contribute a blog post, see our Contributor's Guide for more information.

JetStream for Key-Value Store Tech Preview

R.I. PIENAAR — July 15, 2021

Key-Value stores are specialised NoSQL databases that store values in a data bucket under a specific key. Key-Value stores are used extensively in modern cloud-native infrastructure, indeed etcd is the main storage engine of Kubernetes. In recent releases we have made several enhancements to JetStream with regard to wildcard subject support. In NATS Server 2.3.2 we have all of the features needed for NATS JetStream to be a powerful Key-Value store. Read more...

Using OCSP Stapling with the NATS Java Library

SCOTT FAUERBACH — July 6, 2021

You already know that the NATS Java library can connect to the NATS Server with TLS. The NATS Server now supports OCSP Stapling. To that end, I have built an example on how to set up the SSLContext to use with the NATS Java Library. Mileage may vary, and you will need to incorporate your own certificates and key stores, but this OCSP Example will get you most of the way there. Read more...

NATS Java Client Latency Benchmarking

SCOTT FAUERBACH — June 21, 2021

NATS Java Client Latency Benchmarking Many users have asked to see how the NATS Java client performs specifically in regard to latency. This blog will discuss using the NatsAutoBench program to run a latency test and how to generate a CSV file that can be used to make a histogram. The NatsAutoBench can run a variety of tests. This blog will focus only on the latency testing. Running the Latency Test You can run the latency test from an IDE or a command line, but you will need to build from the source code. Read more...

JetStream Pull Consumers with the NATS.io Java Library

SCOTT FAUERBACH — June 8, 2021

JetStream Pull Consumers with the NATS.io Java Library The last entry in this series talked about push consumers . This entry will demonstrate the basics of a pull subscription. Pull A pull subscription allows you to control when the server sends the client messages. There is one API method call used for creating a pull subscription: JetStreamSubscription subscribe(String subject, PullSubscribeOptions options) throws IOException, JetStreamApiException; subject - every subscription needs a subject options - configure PullSubscribeOptions or use the default configuration PullSubscribeOptions The PullSubscribeOptions allows you to identify the stream name and is a helper for the most common pull ConsumerConfiguration option, the durable name. Read more...

JetStream Push Consumers with the NATS.io Java Library

SCOTT FAUERBACH — June 3, 2021

JetStream Push Consumers with the NATS.io Java Library The last entry in this series talked about the consumer options that are available when subscribing to messages. This entry will demonstrate the basics of a push subscription. Push A push subscription is where the server is in control and sends messages to the client. It can be made durable or ephemeral based on your use case. Here are the API method calls used for creating a push subscription: Read more...

Synchronous and Asynchronous Publishing with the NATS.io Java Library

SCOTT FAUERBACH — May 27, 2021

Synchronous and Asynchronous Publishing with the NATS Java Library In the continuation of the series on using the NATS Java client with JetStream , there is new video that demonstrates publishing messages to a stream synchronously and asynchronously. Check out this video: The source code discussed in the video can be found here: PublishAsync PublishSync.java About the Author Scott Fauerbach is a member of the engineering team at Synadia Communications . Read more...

JetStream Consumers with the NATS.io Java Library

SCOTT FAUERBACH — May 21, 2021

The previous entries in this series showed us how to create JetStream streams and publish messages. This entry will start building up to subscribing by describing the configuration for consumers. Push vs Pull Subscription Consumers, once created, can subscribe as either a push or pull mode. The server sends messages to push consumers while pull consumers have to ask for messages. This is mentioned here first because consumer configuration options may apply differently depending on the type of subscription. Read more...

Replace your MQTT broker with NATS Server

IVAN KOZLOVIC — May 20, 2021

Replace your MQTT broker with NATS Server v2.2.0+ NATS Server v2.2.0+ has native support for MQTT v3.1.1 protocol. If you already have a deployment with existing MQTT broker(s) and use NATS messaging, or are planning to, this blog post will show you how easy it is to replace your existing MQTT broker with a NATS server. Not only you would have to manage a single server instead of two, using NATS with MQTT will allow you to exchange data from MQTT to NATS and vice-versa. Read more...

Java client usage on Android with Kotlin

IVÁN FERRO — May 15, 2021

Java Client Usage on Android with Kotlin Dependencies To use the official NATS.java library in Android we need to add the dependency to the build.gradle file at Module level. Please use the latest released version, which at this writing is 2.11.2 dependencies { //other dependencies implementation 'io.nats:jnats:2.11.2' } Implementation We will create a class as a manager to control our NATS client to be able to connect, disconnect, publish … This is necessary because when nats. Read more...

NATS Java Client JetStream Multi Tool

SCOTT FAUERBACH — May 13, 2021

As we were building the NATS Java client we realized we wanted code to run the client through its paces. We built unit tests, example code and added basic functionality to our existing benchmarking tool. As we talked to prospective users, they were asking for benchmarks across the variety of different ways we can publish and subscribe. For instance see publishing synchronous versus asynchronous. Push versus pull consuming. Different amounts of threading with shared or individual connections to the server. Read more...