Is it possible to create a consumer that receives all available messages at the time of creation and then automatically unsubscribes? #1257
Replies: 2 comments 1 reply
-
@hayleyjames There is no consumer option for that today, but what you can do is do a stream info lookup to get the current sequence (at the time of the lookup) and then consume until you have reached that sequence number to cleanly stop. |
Beta Was this translation helpful? Give feedback.
-
There is a similar solution that may be easier thanks to @piotrpio and @Jarema create the consumer Seems like the CachedInfo() contains correct info while not requiring an extra roundtrip. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm trying to use JetStream as an event store and I'd like to create a consumer that knows when it has seen all the messages on a stream.
I have achieved that behaviour using a pull subscriber, but using a timeout doesn't seem like a reliable way to know when all messages have been processed. Is there a better way that I'm missing?
Thanks,
Hayley
Beta Was this translation helpful? Give feedback.
All reactions