Reputation: 5703
I have created Artemis Cluster with 2 nodes and successfully connected with my Spring-boot app (github link), implementation is based on clustered-static-discovery
Now I am testing Durable subscription with it there is some strange behaviour i am producing 5 msg and consuming only 3
@Bean
public MessageListenerContainer listenerContainer1(@Qualifier("connectionFactory") ConnectionFactory connectionFactory, Consumer consumer, SimpleMessageConverter messageConverter, @Qualifier("topic") Topic topic) {
DefaultMessageListenerContainer defaultMessageListenerContainer =
new DefaultMessageListenerContainer();
@Bean("connectionFactory")
public ConnectionFactory activeMQJMSConnectionFactory(@Qualifier("amqTransportConfiguration") TransportConfiguration transportConfiguration) throws JMSException {
ActiveMQJMSConnectionFactory activeMQJMSConnectionFactory =
new ActiveMQJMSConnectionFactory( false, transportConfiguration);
activeMQJMSConnectionFactory.setPassword("admin");
activeMQJMSConnectionFactory.setUser("admin");
activeMQJMSConnectionFactory.setClientID("admin");
return activeMQJMSConnectionFactory;
}
defaultMessageListenerContainer.setConnectionFactory(connectionFactory);
defaultMessageListenerContainer.setDestination(topic);
defaultMessageListenerContainer.setMessageListener(consumer);
defaultMessageListenerContainer.setSessionAcknowledgeMode(1);
defaultMessageListenerContainer.setSubscriptionName("mySub");
defaultMessageListenerContainer.setSubscriptionDurable(true);
defaultMessageListenerContainer.setMessageConverter(messageConverter);
return defaultMessageListenerContainer;
}
here is whole config
I have go through with http://localhost:816i/hawtio/ wrb UI for artemis and found producer is getting only 5 messsage out of 5
(message-load-balancing -> STRICT)
what am i doing wrong here?
Upvotes: 3
Views: 1150
Reputation: 5703
The problem was in Artemis dependency, existing used dependency somehow unable to handle PubSab connection with the cluster, I have not found any error logs for the missing message. I have changed dependency
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client-all</artifactId>
<version>2.2.0</version>
</dependency>
Now it's working.
Upvotes: 4
Reputation: 3679
Looks like the problem is about the code. Two different durable subscriptions share the same durable subscription name. I was able to pass your test after using unique subscription name for each MessageListenerContainer
instance:
//listener container (1)
defaultMessageListenerContainer.setDurableSubscriptionName("sub1");
/* --- */
//listener container (2)
defaultMessageListenerContainer.setDurableSubscriptionName("sub2");
Upvotes: 0