Closed nuharaf closed 5 years ago
The NATS protocol has the client define a closure or subscription ID that it passes with a SUB to the server. The server treats all subscriptions with different SID (subscription ID) as unique and sends the message for each matching one. We could update the protocol to only send the message once for multiple SIDs, but currently we feel this is not an issue. We will take a look at documentation and make sure its clear, thanks.
@derekcollison thanks,we have the same question. Does any nats-server version support only send the message once for multiple SIDs?
In terms of last mile to a client, a message is sent to all SIDs registered for the client. It simplifies the client logic quite a bit, otherwise clients would need to implement a full blown sublist like we have in the server.
We may have an opportunity to upgrade the client protocol later this year and could add the ability to send a message once with an array of SIDs vs just one however.
I create this issue because I didn't see it stated anywhere in the document. If a client subscribe to an overlapped topic , say subscribing to "*" and ">" or subscribe twice to the same topic , message will be delivered by broker multiple times. I test this with nodejs client and also observe the actual data sent with wireshark.
It is not necessarily a bug per se, but a documentation clarifying this behaviour will help. A few concern :
for comparison, mosquitto broker do not deliver message multiple time on overlapped subscription https://mosquitto.org/man/mosquitto-conf-5.html