NATS Jetstreams creation and management #4457
Replies: 1 comment 2 replies
-
There are a few reasons for the current API-first stance. NATS is a multi tenant system and we support decentralised authorization where no credentials for the accounts are stored on the server. We therefor cannot just add the definitions as in your example as accounts can be managed outside of the server config. Managing accounts, their limits and properties just would not be compatible with also managing streams in this manner NATS is often managed by a central team with users of the system being external - those users cannot access the configuration file, scripts or anything on the server. So we take an API first approach where the client language APIs, the CLI, Terraform or GitHub Actions can be used to create a high quality automated resource management system. It's easy to trigger these systems as a setup container in your container scheduler or from another boot up process if you dont use containers |
Beta Was this translation helpful? Give feedback.
-
I am interested in utilizing NATS as a messaging service to facilitate communication among multiple applications. One observation I've made is that when a consumer begins and attempts to establish a connection in order to consume a stream, this action fails due to the producer not having created the stream yet. This behavior has been documented in the following issue: #3935.
Regrettably, the NATS server lacks the capability to directly configure the streams via the nats.config file. While suggestions such as using nack or terraform-provider-jetstream have been put forth as potential solutions in issue #3935, these may not always be feasible options.
Given this context, I'm seeking guidance on the optimal approach for setting up a NATS server that possesses prior knowledge of the required streams. I'm particularly interested in hearing from individuals who have hands-on experience with managing streams in a production environment.
In terms of potential solutions, I've devised two proposals:
Proposal 1:
Configure the streams preemptively within the nats.config file. This configuration would occur only once. I am aware that implementing a
migration
system for the streams could introduce some complexities.Proposal 2:
Enable the execution of a script during the server's startup phase, as indicated in the server.go file. This script would utilize the Stream Management API to configure and migrate the stream setup, all of this occurring prior to any other client establishing a connection.
streaminit: "/path/to/jetstream/setup-app"
I am eager to gather insights and thoughts regarding these proposals, especially from those who have encountered and resolved similar challenges in real-world scenarios. Your experiences and recommendations would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions