Open mtmk opened 3 months ago
I am facing a similar problem while running multiple NATS jetstream consumers as background operations in .net webapi. Feel like dependency injection operations would also be difficult in this. Comming from Masstransit RabbitMq world implementing these operations are quite easy over there.
Suggestions for samples:
ConsumerAsync
loop and send them all as a batch for processing and then acknowledge them.NatsConnection
vs NatsConnectionPool
- when to use either one or the otherI just came up with a fun/useful idea!
General thought, what if we could use Jetstream and/or KV (I'm thinking primarily KV here) for implementing a JWT jti
token validator?
As a background, jti
is an optional field in JWTs intended to prevent replay
of a token; if included it is expected to be used only once across the auth context.
My general thought being, a service could take in JTIs along with an expiration time, and then return whether the JTI has been used or not. The assumption being, the consumer will be pre-checking expiration as part of normal JWT flow, so one could set an expiration time on the buicket of the ceiling for JWT lifetime.
I'm pretty sure it would be fairly easy to wire up, also could be expandable to something like 'use NATS in ASPNETCORE middleware' case.
(I'm willing to give this a crack but if someone else wants to beat me to it, all the better.)
Those are some great examples to consider! Some are very .NET specific, but most are general NATS challenges, that can be fact by using any client. I would love if those ideas were somehow realized in a way, that provides a solution in each major client.
Maybe a section in https://natsbyexample.com that is focused on Real-World examples would be a good idea, maybe some other medium.
Problem Statement: Users coming from other messaging platforms (e.g. RabbitMQ, Masstransit) might find it challenging to register NATS constructs (e.g. consumers) and process messages in the current setup. Most examples and samples provided are overly simplistic, often showcasing a single consumer in a console application. There is a need for more realistic examples, particularly for long-lived services with multiple consumers.
Proposed Enhancements:
Benefits: