Creating durable subscriber using Polling Consumer

2019-09-12 05:22发布

问题:

I am trying to create a durable subscriber using polling consumer. The URI is correct as same uri is working when used in camel route and durable subscriber is correctly created. For some reason PollingConsumer is not able to create durable subscriber and instead creates normal subscriber.

Is it not possible to create durable subscribers using polling consumer?

public class OutQWaitingProcesser implements Processor {

    @Override
    public void process(Exchange exchange) throws Exception {
        Endpoint endpoint = exchange.getContext().getEndpoint("jms:topic:response?clientId=5&durableSubscriptionName=abcd");
        PollingConsumer consumer = endpoint.createPollingConsumer();
        consumer.start();
        Exchange exchange2 = consumer.receive();
        String body = exchange2.getIn().getBody(String.class);
        exchange.getIn().setBody(body);
        consumer.stop();
    }
}

回答1:

Camel JmsPollingConsumer is based on Spring JMSTemplate which doesn't support to set the durableSubscription option.