Subject: Request for Example Code: Java Pub-Sub with File Persistence using NATS JetStream

11 views
Skip to first unread message

M Raja

unread,
Oct 28, 2024, 12:48:34 PM10/28/24
to nats
Hi ,

Currently i m  implementing a publish-subscribe messaging system using NATS JetStream with file-based persistence in Java. To ensure that I follow best practices and leverage the full capabilities of NATS JetStream, I would greatly appreciate it if you could provide me with some example code or resources that demonstrate this setup.

Specifically, I am looking for examples that cover:

Setting up a NATS JetStream with file storage.
Publishing messages to a JetStream.
Subscribing to messages from a JetStream and handling them appropriately.
Any guidance, sample code, or documentation you can share would be immensely helpful.

Thank you in advance for your assistance. I look forward to your response

Scott Fauerbach

unread,
Oct 28, 2024, 6:52:03 PM10/28/24
to nats
The Java JNats Client repo is a great place to start.  At the top of the page are several links to examples:

NATS by Example  is a great place to start, it has many basic examples in multiple languages and provides a great way to jump in and learn fundamental NATS usage, like publishing and subscribing.
The examples directory in the JNats GitHub repo has many examples and covers more than just basic use of the client, including many examples where a stream is created and several varieties of publishing and subscribing.
The Java Nats Examples GitHub repo has a collection of more in depth use case examples.

Also check out the latest Java API docs.

Another resource is of course the official NATS documentation

And last but not least, please join our public Slack 
Reply all
Reply to author
Forward
0 new messages