Why we want to persist messages?
- There are a number of cases where messages are required to be available for consumers that were disconnected from the broker, so we want these messages to survive in long-term storage.
Why to want to use cache?
- For some real-time data delivery cases, it's pointless to persist because new messages will arrive soon.
How caching works for topic consumer?
- ActiveMQ will cache messages in memory for every topic but only dispatch them to 'retroactive' topic consumers not 'durable' ones.
How to create retroactive topic consumer?
Topic topic = session.createTopic("TEST.TOPIC?consumer.retroactive=true");
MessageConsumer consumer = session.createConsumer(topic);
Subscription recovery policy
- We can configure this policy about what types of messages to cache, how many, how long(duration).
fixedSizeSubscriptionRecoveryPolicy : how large the messages.
fixedCountSubscriptionRecoveryPolicy : how many messages.
lastImageSubscriptionRecoveryPolicy : cache the last message.
timedSubscriptionRecoveryPolicy : how long to cache
noSubscriptionRecoveryPolicy : disable the cache.
Any cache for Queue?
No. The normal operation for queue is to hold every message sent to it.