1

I have been doing some POCs with NATS and NATS streaming servers for past few days. I started with NATS-streaming server by writing a Java client for the same and publishing/subscribing messages to/from NATS-streaming server, clustered along with NATS server. NATS-streaming is pretty neat with providing acknowledgement guids when the streaming server receives a message from a publisher. I achieved this by registering an AckHandler and using it like so:

guid[0] = sc.publish("produceQueue", payload, new AckHandler() {
                @Override
                public void onAck(String nuid, Exception ex) {
                    LOGGER.debug("Received ACK for guid: {}", nuid);
                }

                System.out.flush();
                latch.countDown();
        }
    });

However, when I started looking at NATS server (not streaming), I could not find any such AckHandlers (or anything else) which can provide me with an acknowledgement guid to denote that a message has been successfully published.

NATS-streaming server has a lot of built in functionality that I'm looking for - for instance, message acknowledgements, max_age (TTL for a message), durable subscriptionsetc. But it lacks the clustering capability with the current latest version which is out there. On the other hand, NATS server provides the clustering functionality, but I could not find the other features that NATS-streaming provides (unless I've missed it in the documentation).

I know there's an open issue to get NATS vs NATS-streaming capabilities outlined in a single table to be referred to, but its still not done as of yet.

Does NATS server provide with acknowledgements when a message is published to the NATS server? Or an acknowledgement of a message being subscribed by one of the subscribers?

Addle Pate
  • 41
  • 1
  • 3

1 Answers1

2

I know if has been a long time and you may not be interested by the answer at this point but here it is:

NATS Streaming does now have support for clustering.

But back to your question about core NATS: there is no acknowledgment sent back from the server. This is the nature of NATS, fire and forget. Now, if your sending application needs to know that the message has been processed by the subscriber, you could use Request/Reply. That is, the subscriber getting the message can send a message back to the incoming message's Reply subject. The requestor has the option to set a timeout to dictate how long to wait for the response. It has then to make a decision as to what to do if it does not get the reply: resend? give up? Note that the subscription may have processed the request and the reply was missed (either crash, network issue, requestor just timed-out), so you would need some kind of way of detecting that the request was already processed. This is true with NATS Streaming too. There is an at-least-once guarantee, not at-most-once.

I. Kozlovic
  • 796
  • 3
  • 3