我将DefaultMessageListenerContainer配置为侦听来自WebLogic JMS的消息。 WebLogic实例有两个实例。我注意到消费者总是只去一个实例而且它不会在实例之间共享。
有人可以告知这是由于DefaultMessageListenerContainer配置问题还是JMS实例问题?
@Bean
public DefaultMessageListenerContainer defaultMessageListenerContainer(MessageListenerAdapter eventListenerAdapter,
ConnectionFactory connectionFactory,
Destination destination) {
DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
messageListenerContainer.setSessionTransacted(true);
messageListenerContainer.setMessageListener(eventListenerAdapter);
messageListenerContainer.setMessageSelector("id='1' and name='department'");
messageListenerContainer.setDestination(destination);
messageListenerContainer.setConcurrency("3-6");
messageListenerContainer.setConnectionFactory(connectionFactory);
return messageListenerContainer;
}
@Bean(name = "destination")
public JndiObjectFactoryBean destination(JndiTemplate jndiTemplate) {
JndiObjectFactoryBean queueJndi = new JndiObjectFactoryBean();
queueJndi.setJndiTemplate(jndiTemplate);
queueJndi.setJndiName("DEPT_QUEUE");
return queueJndi;
}
@Bean(name = "connectionFactory")
public ConnectionFactory connectionFactory() {
return (ConnectionFactory) jmsConnectionFactory().getObject();
}
@Bean(name = "eventListenerAdapter")
public MessageListenerAdapter eventListenerAdapter() {
MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(processEventsListener);
messageListenerAdapter.setDefaultListenerMethod("processEvents");
messageListenerAdapter.setMessageConverter(null);
return messageListenerAdapter;
}
答案 0 :(得分:1)
通过取消选中负载均衡" Server Affinity Enabled"解决了该问题。属性