Skip to content

v1.2.0

Compare
Choose a tag to compare
@aricart aricart released this 25 Aug 21:43
· 708 commits to main since this release
dc0322e

BREAKING CHANGES

This release contains a set of changes that are API-breaking for JetStream. Since the JetStream APIs on the JavaScript clients are Preview, only the minor version of the client has been bumped. Because of these changes, you should carefully read the Breaking Changes section to ensure you are not affected.

JetStream Push Consumers In Queue Groups

The Push Consumer Queue feature has changed. A new nats-server (2.4.0) is in the works that modifies how this feature works.
The new JavaScript clients have been modified to work with the new server and will fail to work with an existing server using push consumers with queue groups.

Previously it was possible to create a push consumer and properly get it working in a queue group with a regular NatsConnection#subscribe or NatsConnection#jetstream()#subscribe() if all queue subscriptions used the same queue name and no plain (non-queue) subscriptions were used.

If the mix of subscriptions and queues referenced the same consumer but provided different queue names or no queue names, the delivery of messages was incorrect and could create conditions where some messages were seen in duplicate or have unexpected side effects.

The new nats-server changes will make an old consumer configuration with a queue group a noop - the server will not send messages to the client. To enable a queue group to work on a consumer:

  • The consumer configuration must specify a deliver_group matching the queue group name.
  • Configurations that use the consumer with a non-matching queue group will be invalid.
  • Configurations that use a queue group consumer without a queue group will be invalid.

The nats client for JavaScript on 1.2.0 and beyond, enforces the above rules, so an Error is thrown from NatsConnection#jetstream().subscribe() for configurations that try to use the queue group incorrectly.

Because an old server will not report deliver_group for the consumer, any jetstream#subscribe() that attempts to specify a queue group will fail the validation.

If you are creating nats your own nats subscription to handle the consumer, and have an old server, you may continue to do that until you upgrade the server, at which point the nets-server will stop delivering messages to your client. Please do ensure that you don't use the consumer from different queue groups in the meanwhile.

JetStreamManager#streams#getMessage(number)

This API has been removed (it was deprecated and printing console messages). To retrieve a message by its sequence,
replace with JetStreamManager#streams#getMessage({seq: number}).

Other Changes

  • [FIX] JetStream ConsumerInfo type was not exported. Also changes SequencePair to be named SequenceInfo to match changes in the server. These types were only referenced from ConsumerInfo which was not exported.

  • [FEAT] Added DeliveryPolicy#LastPerSubject which allows a consumer to get the last message for each subject in a stream.

  • [FIX] Exported functions millis(ns: number):number and nanos(millis: number):number to allow conversion between these number types. millis() converts nanoseconds to millis, and nanos() millis to nanoseconds) - some of the JetStream APIs expose these values and the client may want to translate to something more meaningful. Note future versions may change the return values of these functions to bigint`.

  • [FIX] Stats (NatsConnection#stats(): Stats) and ServerInfo (NatsConnection#info), PubAck (return type for JetStream#publish(), are now exported types.

  • [FEAT] Exported isNatsError(), checkJsError(), isFlowControlMsg(), isHeartbeatMsg as these are sometimes useful for lower level subscriptions handling JetStream messages.

  • [FEAT] PubAck now reports a domain field representing the JetStream domain if set or returning an empty string. This feature requires a newer server.

  • [FIX] ConsumerConfig now have fields deliver_group, description.