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.

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...

Pub-Sub with NATS CLI

R.I. PIENAAR — May 11, 2021

Publish-Subscribe with NATS CLI Previously we introduced the New NATS CLI , today we look at the Publish-Subscribe pattern using the CLI. Links to related documentation: Subjects-Based Messaging Publish-Subscribe Queue Subscriptions Request-Reply The NATS CLI About the Author R.I. Pienaar is a long-time NATS Maintainer and a senior member of the engineering team at Synadia Communications . Read more...

Hello World with the NATS.io Java Library

SCOTT FAUERBACH — May 5, 2021

Hello World with the NATS Java Library Recently, stream functionality was added to the NATS server in release 2.2. See our JetStream section in docs for additional information. Check out this video where I discuss the basics of how to create a stream and then publish and consume messages using the NATS Java client . The full source of the project can be found here: https://github.com/nats-io/java-nats-examples/tree/main/hello-world About the Author Scott Fauerbach is a member of the engineering team at Synadia Communications . Read more...

JetStream Publishing with the NATS.io Java Library

SCOTT FAUERBACH — May 3, 2021

The previous entry in this series showed us how to create a stream. Once you have defined a stream, you can publish to the configured subjects. Publishing to stream subjects isn’t really much different from publishing a regular NatsMessage. Once a subject is established, you could publish a regular NatsMessage to that subject, but there are benefits to publishing via the JetStream API instead of the regular message API. Publish Acknowledgement When you publish via the JetStream API, each publish will receive an acknowledgement or PublishAck. Read more...

JetStream Stream Creation with the NATS.io Java Library

SCOTT FAUERBACH — April 29, 2021

The NATS Java library with support for JetStream has just been released! JetStream allows you to persist streams of messages, allows consumers to either subscribe in real time or to access the messages at a later time with the added flexibility to choose from where in the stream you want to start receiving messages. You can start reading from the stream at a specific point in time or start at a specific message sequence number. Read more...

Intro NATS CLI

R.I. PIENAAR — April 27, 2021

Introducing NATS CLI Historically NATS did not have a clear obvious place to go for a CLI tool, users had various example applications that had to build and run manually. These tools were primarily examples of using the APIs rather than full UX CLI experience. As part of the NATS 2.2.0 release that introduced JetStream and its administration needs, we took the opportunity to build a full CLI tool for users and administrators alike. Read more...

Headers with the NATS.io Java Library

SCOTT FAUERBACH — April 17, 2021

A few months ago, Header support was added to NATS Server. With the release of the 2.10.0 Java client , Headers are completely supported. NATS Headers are analogous to http request Headers and you can leverage them for the same type of things, for example, to pass information like security, request, transaction or state information. In Java terms, it’s analogous to a map of type Map<String, List<String>> In fact, that’s exactly what is used for the backing data structure in the Headers object. Read more...

What's New in NATS 2.2

COLIN SULLIVAN — April 12, 2021

Overview NATS 2.2 is the largest feature release since version 2.0. The 2.2 release provides highly scalable, highly performant, secure and easy-to-use next generation streaming in the form of JetStream, allows remote access via websockets, has simplified NATS account management, and provides native MQTT support built into the server. These features further enables NATS toward our goal of securely democratizing streams and services for the hyperconnected world we live in. Read more...