moleculerjs / moleculer-channels

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

Add options for enable one-time assertExchange calling #63

Closed Storm8719 closed 1 year ago

Storm8719 commented 1 year ago

If no one created exchange before the broker.sendToChannel() was called - we getting AMQP channel error 404 issue. Think it would be useful to add the ability to enable a one-time assertExchange() call before the first publish to a new exchange. So that there is no dependence on third-party services and we know that the exchange will definitely be created

Storm8719 commented 1 year ago

Hi @icebob. Thanks for your reply. In the new commit I set a fixed exchangeType and renamed the variables. Regarding the third point: If you mean different exchangeOptions for different calls broker.sendToChannel(channelName, payload, opts) - now we can directly set these values ​​in opts. For example:

this.broker.sendToChannel("some.channel", {
        id: 1234,
    },
    {
        publishAssertExchange: {
            enabled: true,
            exchangeOptions: {
                durable: false
            }
        },
    }
);

Options that are specified directly in broker.sendToChannel will have more priority than ones specified in the general adapter config.

Edits have also been added to the readme with example

icebob commented 1 year ago

Thank you!