The previous entry, JetStream Stream Creation with the NATS.io Java Library in this series showed us how to create a stream. Once you have defined a stream, you can publish to the configured subjects. Publishing to stream subjects isn't really much different from publishing a regular NatsMessage. Once a subject is established, you could publish a regular NatsMessage to that subject, but there are benefits to publishing via the JetStream API instead of the regular message API.
Publish Acknowledgement
When you publish via the JetStream API, each publishes will receive an acknowledgment or PublishAck
. This is the server's way of letting you know it has received the message and has handled it according to the options like storage, retention, and replication that were established when creating the stream.