How do I apply the lastImageSubscriptionRecoveryPolicy subscription policy to either a destination or a consumer?

StackOverflow https://stackoverflow.com/questions/22791246

  •  25-06-2023
  •  | 
  •  

Question

I have a topic that I'd like to have consumers subscribe retroactively with the lastImageSubscriptionRecoveryPolicy. I'm not using a config file, I'm specifying everything via Java code. I'm creating the topic like:

session.createTopic("a.topic?consumer.retroactive=true");

How do I go about specifying that this should be lastImageSubscriptionRecoveryPolicy for this topic in Java code? Note: I don't want to specify that all my topics are lastImageSubscriptionRecoveryPolicy (so I don't want to call broker.setDestinationPolicy(pMap);).

Was it helpful?

Solution

This isn't exactly what I wanted, but it's close enough:

PolicyMap policyMap = broker.getDestinationPolicy();
PolicyEntry policy = new PolicyEntry();
policy.setSubscriptionRecoveryPolicy( new LastImageSubscriptionRecoveryPolicy() );
ActiveMQDestination destination = (ActiveMQDestination) session.createTopic(
   "a.topic" );

policyMap.put( destination, policy );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top