rabbitmq-jms-client icon indicating copy to clipboard operation
rabbitmq-jms-client copied to clipboard

Session re-creates durable JMS topic exchange between restarts

Open acogoluegnes opened this issue 8 months ago • 0 comments

The library creates a session-scoped durable JMS topic exchange for durable topic subscribers with a selector. It uses a UUID in the name. The exchange is not deleted between restarts (to keep messages for closed durable subscribers), so a new session would create yet another exchange. The documentation explains this design. A new binding with the selector arguments is created between the exchange and the subscriber queue.

This avoids creating an exchange for each subscriber, but it makes it impossible to re-use the existing exchange, making the exchanges leak until the subscribers unsubscribe.

It'd be more appropriate to create a dedicated exchange for each durable subscriber with a selector. The name would be based on the topic and subscription names (using a hashing mechanism, to control the length), this way the exchange could be re-used between restarts.

The name could use a MD5 of the topic and subscription names, with a base 64 encoding (+ replaced by -, / by _, = removed). This is the algorithm used for server-named queues.

Original discussion: #454

acogoluegnes avatar Jun 20 '24 13:06 acogoluegnes