moleculerjs / moleculer-channels

Reliable messages for Moleculer services via external queue/channel/topic.
MIT License
75 stars 15 forks source link

durable_name NATS option being overwritten. #52

Closed isaac-nls closed 1 year ago

isaac-nls commented 1 year ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Current Behavior

Specifying the durable_name consumer option for NATS is not possible as it gets overwritten with the name of the service. This is important, as defining ephemeral streams in NATS requires that this option be set to null.

Expected Behavior

The durable_name consumer option can be set and does not get overridden. Perhaps if not specified, the option can default to the name of the service.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Specify the durable_name option in the middleware construction

    ChannelsMiddleware({
    adapter: {
        type: "NATS",
        options: {
            nats: {
                consumerOptions: {
                    config: {
                        durable_name: "TESTING123"
                    }
                }
            },
        }
    }
    }),
  2. Add a console.log / breakpoint in ./src/adapters/nats.js:212 to print the consumer options

E.g.

...
consumerOpts.queue = streamName;
consumerOpts.config.deliver_group = streamName;
// NATS Stream name does not support: spaces, tabs, period (.), greater than (>) or asterisk (*) are prohibited.
// More info: https://docs.nats.io/jetstream/administration/naming
consumerOpts.config.durable_name = chan.group.split(".").join("_");
consumerOpts.config.deliver_subject = chan.id;
consumerOpts.config.max_ack_pending = chan.maxInFlight;
consumerOpts.callbackFn = this.createConsumerHandler(chan);

console.log("OPTS", consumerOpts) // PRINT THE CONSUMER OPTIONS

// 3. Create a subscription
try {
    const sub = await this.client.subscribe(chan.name, consumerOpts);
    this.subscriptions.set(chan.id, sub);
} catch (err) {
...

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Thanks in advance! Isaac

icebob commented 1 year ago

What is your use-case to use ephemeral messages? We created this library to add a reliable message sending option to Moleculer. Disabling durability breaks this feature.

icebob commented 1 year ago

Close due to inactivity