0
votes

Is it possible to set expiration for queues or addresses if we use durable subscriptions in STOMP?

Artemis automatically deletes auto-created queues by default, but "durable" subscription queues remain forever. I've tried setting the expiry-delay address-setting which will delete the messages if no expiry-address is defined. However, Artemis keeps the subscription queues anyway which causes the server to run out of memory. I have to delete container in Docker every 3 days. As you can imagine, this is not good at all.

Unfortunately, it often happens when the client closes the browser without unsubscribing.

Here is the relevant portion of broker.xml:

<address-setting match="#">
    <expiry-delay>3600000</expiry-delay> <!-- 1 hours -->
    <default-address-routing-type>MULTICAST</default-address-routing-type>

    <dead-letter-address>DLQ</dead-letter-address>
    <!--<expiry-address>ExpiryQueue</expiry-address>-->
    <redelivery-delay>15000</redelivery-delay>
    <max-delivery-attempts>10</max-delivery-attempts>

    <max-size-bytes>-1</max-size-bytes>
    <address-full-policy>PAGE</address-full-policy>
    <auto-create-addresses>true</auto-create-addresses>
    <auto-delete-addresses>true</auto-delete-addresses>

    <auto-create-queues>true</auto-create-queues>
    <auto-delete-queues>true</auto-delete-queues>

    <auto-create-jms-queues>true</auto-create-jms-queues>
    <auto-create-jms-topics>true</auto-create-jms-topics>
    <auto-delete-jms-queues>true</auto-delete-jms-queues>
    <auto-delete-jms-topics>true</auto-delete-jms-topics>
</address-setting>
2

2 Answers

0
votes

After upgrading to 2.15.0, it works as expected.

Caused by: org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element 'auto-delete-delay'.

My current configuration:

<expiry-delay>3600000</expiry-delay> <!-- 1 hours -->
<auto-delete-created-queues>true</auto-delete-created-queues>
<auto-delete-queues-delay>3600000</auto-delete-queues-delay> <!-- 1 hours -->

This will delete queues after a specified time that have no messages and have not been unsubscribed from properly

0
votes

The queues used for STOMP durable subscriptions are not considered to be auto-created since the client is specifically asking for a durable subscription. The whole point of having a durable subscription is so that it will retain messages which are sent while the client is not connected. If the client disconnects without unsubscribing the assumption is that it will eventually reconnect and consume the messages in its durable subscription.

Of course, some clients won't do that which is the problem you're facing. You might consider if durable subscriptions are really what you want. Non-durable subscriptions won't suffer from this problem, of course.

However, if you must use durable subscriptions then you should set auto-delete-created-queues to true and you can tune the auto-delete-queues-message-count and auto-delete-queues-delay to fit your needs, e.g.:

<address-setting match="yourAddress">
    <auto-delete-created-queues>true</auto-delete-created-queues>
    <auto-delete-queues-message-count>-1</auto-delete-queues-message-count>
    <auto-delete-queues-delay>3600000</auto-delete-queues-delay>
</address-setting>

This combination of settings will ensure that any durable subscription queue on the address yourAddress is deleted 1 hour after the last consumer disconnects no matter how many messages it contains.

Also, be aware the these settings are deprecated so you shouldn't use them:

<auto-create-jms-queues>true</auto-create-jms-queues>
<auto-create-jms-topics>true</auto-create-jms-topics>
<auto-delete-jms-queues>true</auto-delete-jms-queues>
<auto-delete-jms-topics>true</auto-delete-jms-topics>