Skip to content

Using Nats Jetstream as an event store #3772

Answered by bruth
cloudcompute asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @cloudcompute. Answers in order:

a. The short answer is yes. A stream in NATS (JetStream) is very well suited for event sourcing since every event can be published/appended to a subject that represents an aggregate/entity/consistency boundary of your choosing. For example, a stream called orders with subjects orders.* bound to it. Then all publishes/appends to orders.1, orders.2, etc. would be appended to that stream.

You can enforce optimistic concurrency on a stream-level or a per-subject level within a stream using a message header, Nats-Expected-Last-Sequence or Nats-Expected-Last-Subject-Sequence, respectively, whose value is the expected sequence. Of course, if the sequence in th…

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
4 replies
@yordis
Comment options

@gedw99
Comment options

@matthewadams
Comment options

@matthewadams
Comment options

Answer selected by cloudcompute
Comment options

You must be logged in to vote
4 replies
@bruth
Comment options

@cloudcompute
Comment options

@cloudcompute
Comment options

@bruth
Comment options

Comment options

You must be logged in to vote
3 replies
@bruth
Comment options

@shafqatevo
Comment options

@gedw99
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants