user3007165
user3007165

Reputation: 479

How to subscribe to a Durable TOPIC using Apache camel / Spring-boot?

Whenever i start my subscriber, it is not appearing on my activeMQ under "Active Durable Topic Subscribers" section. Which means it is not a durable topic subscriber yet. How can i make it durable subscriber?

JmsComponent jmsComponent = JmsComponent
        .jmsComponentTransacted(connectionFactory, jmsTransactionManager);
// TODO
jmsComponent.setClientId(subscriptionClientId);
jmsComponent.setDurableSubscriptionName(subscriptionName);
jmsComponent.setSubscriptionDurable(true); // This is enabled by default
//jmsComponent.setMaxConcurrentConsumers(maxConcurrentConsumers);
jmsComponent.setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);

return jmsComponent;

P.S: It works fine for Non-durable subscribers. I added the below code in an attempt to make it durable. Am i missing something ? Do i need to add anything else?

jmsComponent.setClientId(subscriptionClientId);
jmsComponent.setDurableSubscriptionName(subscriptionName);
jmsComponent.setSubscriptionDurable(true); // This is enabled by default

Upvotes: 0

Views: 1787

Answers (1)

user3007165
user3007165

Reputation: 479

I got it working by passing the subscription details as query string param as below;

myapp.jms.topic.inbound1=jms:topic:myFirstTopic?clientId=ABC&durableSubscriptionName=ABC

myapp.jms.topic.inbound2=jms:topic:mysecondTopic?clientId=XYZ&durableSubscriptionName=XYZ

Upvotes: 2

Related Questions