简体   繁体   中英

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;

PS: 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM