quarkiverse / quarkus-reactive-messaging-nats-jetstream

Easily integrate to NATS.io JetStreams
https://docs.quarkiverse.io/quarkus-reactive-messaging-nats-jetstream/dev/index.html
Apache License 2.0
8 stars 5 forks source link

Publish Message to NATS with dynamically created subjects #85

Closed dharriso closed 4 months ago

dharriso commented 5 months ago

Hi

Thanks for providing a Quarkus Reactive message connector for NATS. I have been using NATS Java client for a year or more now and only recently became aware of this extension.

However I have a requirement where I need to publish messages to NATS where the subject parameter is dynamically generated based on an identity provided as part of the payload body i.e. publish(subject, headers, body).

However the subject line in the configuration provides only a static value. Which means that all message on the stream have the same value. For example I would like to define a stream called called "Events" and where the subject line "Events.>". I would like to add messages with subject "Events.cluster.<0-128000>", e.g. "Events.cluster.68", "Events.cluster.123123" etc.

Is there a way to provide a dynamic subject that can be used here? Im also newbie to Quarkus Reactive messaging.

Thanks in advance Declan

kjeldpaw commented 5 months ago

Hi @dharriso I'm working on implementing this use case. I'm working on solution where it's possible to add metadata for outgoing messages. In the metadata it will be possible to overrule the configured subject on the channel. I'll let you know when it's implemented and released

dharriso commented 5 months ago

Thanks @kjeldpaw for the quick response. looking forward to getting my hand on it

kjeldpaw commented 4 months ago

In version 1.6.0 it's possible to publish a message where the subject is created dynamically using the io.quarkiverse.reactive.messaging.nats.jetstream.util.JetStreamStreamUtility. I used a utility class because I didn't think it fit into messaging framework.

I also have a use case where we need the functionality. I will try use the utility and maybe do some changes to class.

dharriso commented 4 months ago

Thanks @kjeldpaw for resolving this issue. I will take a look at this early next week hopefully. is there any documentation on how to use this new feature? Or should i refer to a specific test example file?

Thanks again Declan