springspring-bootspring-jmswso2-message-broker

assign name in spring jms topic


I am using spring JMS to connect to WSO2MB server. Everything is working fine, but all listeners are assigned the same id. To make it unique, I provided clientId but it is not working. I am not finding any other field where I can provide the name.

I even provided id on the JMS listener but no success.

@Bean
@ConditionalOnProperty(name="my.listener.active", matchIfMissing = true)
public JmsListenerContainerFactory jmsListenerContainerFactory(@Qualifier("listenerConnectionFactory") ConnectionFactory connectionFactory) throws URLSyntaxException {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setClientId("listener"+listenerTopic);
    if (Boolean.valueOf(listenerTopic)) {
        factory.setSubscriptionDurable(true);
        factory.setPubSubDomain(true);
    }
    return factory;
}

@JmsListener(destination = "${default-queue-name-to-listen}", id = "${default-queue-name-to-listen}")
public void receiveMessage(final Message<T> message) throws JMSException {
}

Solution

  • subscription name made the connection name unique and resolved my problem

    @JmsListener(
            destination = "${default-queue-name-to-listen}",
            subscription = "${default-queue-name-to-listen}"
        )
        public void receiveMessage(Message<T> message) throws JMSException {}