For example, we have a durable topic consumer and some broker for that topic. As far as I understand that broker will continue to store every message (within some limits) even if that durable consumer is not active for a very long time.
Is there some broker’s policy in ActiveMQ to destroy (auto unsubscribe) inactive (for some specified time) durable consumers? So that I don’t need to monitor if all consumers still valid and actually exist.
I would suggest you to use virtual topics instead of durable consumers.
When using virtual topic all your messages from producer are sent the same way you send them now. However when a new consumer registers with a unique consumer name – a new queue is created for him, and all messages sent to virtual topic are duplicated into the queue. That means each consumer has his own queue – which is much more convenient than durable topic subscription.
Then when you know for sure your consumer no longer exists – you can delete the queue with all pending messages in it. It can be done whether from code or manually through AMQ web console or jconsole.
EDIT:
With virtual topic you get a new queue for every single consumer, therefore you can apply queue policy to delete it when inactive for a specified period of time.
In your activemq.xml set gcInactiveDestinations=true:
Read more:
http://activemq.apache.org/delete-inactive-destinations.html