NATS JetStream atomic batch publish for event store (NATS 2.12) #23
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ash/eskit#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
NATS 2.12 introduced atomic batch publishing — all-or-nothing multi-message commits. This is critical for event sourcing where a single command can produce multiple events that MUST be persisted atomically.
Why
When
Decide()returns 3 events, all 3 must persist or none. Without atomic batch:PublishMsgAsyncwhich is NOT atomic — individual messages can fail independentlyHow it works (NATS 2.12)
AllowAtomicPublish: trueNATS-Batch-ID,NATS-Batch-Sequence,NATS-Batch-CommitNATS-Expected-Last-Sequence(per stream or per subject)Ref: https://www.synadia.com/blog/atomic-batch-publishing-nats-2-12
ADR: https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-50.md
Implementation
NATSEventStore.Append
NATS-Expected-Last-Subject-Sequencefor OCC on first messageStream setup
AllowAtomicPublish: trueon stream creationCommandBus integration
Tests
Competitive Advantage
Myrra does NOT have this. This makes eskit the first Go ES library with true atomic multi-event commits on NATS.
ash referenced this issue2026-02-19 22:05:43 +00:00