Skip to content

Commit 46864fb

Browse files
committed
set the auto-delete to true for broker queues created to support non-durable topics with autogenerated names
Broker queues defined for Topic consumers of non-durable Topics are assigned auto-generated names that are not visible to JMS clients. These broker queues are inherently transient and were previously (correctly) unbounded when the connection to the broker was closed. However, because these broker queues are created per consumer, the broker would effectively leak these until the connection was closed. This change flags such broker queues with the auto-delete flag, enabling the broker to expunge them once the last consumer is closed.
1 parent 7854597 commit 46864fb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/rabbitmq/jms/client/RMQSession.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,10 @@ private void declareRMQQueue(RMQDestination dest, String queueNameOverride, bool
822822
this.channel.queueDeclare(queueName,
823823
durable,
824824
exclusive,
825-
false, // autoDelete - exclusive takes care of this
825+
/* broker queues declared for a non-durable topic that have an auto-generated name must go down with
826+
consumer/producer or the broker will leak them until the connection is brought down
827+
*/
828+
!durable && queueNameOverride != null && !dest.isQueue(), // autoDelete
826829
options); // object properties
827830

828831
/* Temporary or 'topic queues' are exclusive and therefore get deleted by RabbitMQ on close */

0 commit comments

Comments
 (0)