0

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 {
}
4

2 回答 2

0

订阅名称使连接名称唯一并解决了我的问题

@JmsListener(
        destination = "${default-queue-name-to-listen}",
        subscription = "${default-queue-name-to-listen}"
    )
    public void receiveMessage(Message<T> message) throws JMSException {}
于 2017-05-04T21:51:51.880 回答
0

每个连接都需要有一个唯一的clientID

无效 org.apache.activemq.ActiveMQConnectionFactory.setClientID(字符串 clientID)

设置 JMS clientID 以用于创建的连接。请注意,这一次只能由一个连接使用,因此通常最好在连接上设置 clientID

你的解决方案是使用org.springframework.jms.connection.SingleConnectionFactory

于 2017-05-03T13:10:16.493 回答