3

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?

Bhushan Uniyal
  • 5,575
  • 2
  • 22
  • 45
  • I have a two-broker cluster with STRICT message load balancing (from `clustered-static-discovery` example), and your test runs just fine. I also uncommented those parts that made subscription durable, and that also succeeds. Edit your question and provide us with broker.xml. – Art Licis Dec 12 '17 at 00:24
  • hi @ArtursLicis thank for your response, here is 1st server broker.xml:https://github.com/techguy-bhushan/ApacheArtemisCluster/tree/master/broker/server0 2nd server broker xml ->https://github.com/techguy-bhushan/ApacheArtemisCluster/tree/master/broker/server1 – Bhushan Uniyal Dec 12 '17 at 05:54
  • Also I have uncommented the subscriber line also remove client id from connectionFactory , please take a pull of clone code and re-run test, Can you please share your cluster broker XML. I am not sure where I am doing the thing wrong on broker side or spring configuration. – Bhushan Uniyal Dec 12 '17 at 08:50
  • You definitely checked in either wrong config or unworking code. In your app, you try to connect to a port 9616, which is never defined in configs -- thus startup fails. When I changed this 61616 (first server), it fails with security exceptions (to fix that, you either switch off security or configure it property). It looks like you just need to double check all your configs & setup. – Art Licis Dec 12 '17 at 09:59
  • sorry actually i have tested with 9616 port, i forget to change it's before push , If you replcae it with 61617 it still not working – Bhushan Uniyal Dec 12 '17 at 10:16
  • also i think security exceptions is because you have created your server with different username and password, if you replace ```activeMQJMSConnectionFactory.setPassword("admin"); activeMQJMSConnectionFactory.setUser("admin");``` with your username and password then it will not throw any security exception – Bhushan Uniyal Dec 12 '17 at 10:19
  • also please change the port ```TransportConfiguration(NettyConnectorFactory.class.getName(), getParams("9616"));``` with 61617 or 61616 – Bhushan Uniyal Dec 12 '17 at 10:20
  • @ArtursLicis have you test it. – Bhushan Uniyal Dec 13 '17 at 07:49

2 Answers2

4

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.

Bhushan Uniyal
  • 5,575
  • 2
  • 22
  • 45
0

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");
Art Licis
  • 3,619
  • 1
  • 29
  • 49
  • if you will see from the web UI all message is going to one node instead of load balance (round robin way)between both 2 nodes.. can you please share your cluster configuration – Bhushan Uniyal Dec 14 '17 at 17:24
  • if you will run https://github.com/jbertram/activemq-artemis/blob/clustered-durable-subscription-static-discovery/examples/features/clustered/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java (please remove connection3 and connection4 before run) then you will see load is balanced between both node – Bhushan Uniyal Dec 14 '17 at 17:51
  • That example is doing one trick with acquiring connections: at first, initialConnection is created which is not used, and only after 2 secs delay, the rest of connections are created which are load balanced between all servers. Pay attention to comment in that code: `grab an initial connection and wait, in reality you wouldn't do it this way but since we want to ensure an equal load balance we do this and then create 4 connections round robined`. – Art Licis Dec 14 '17 at 21:32
  • I have created initial connection but issue is samw – Bhushan Uniyal Dec 14 '17 at 21:34
  • Thanks, this was a valuable experience. Surprisingly, I had a similar situation recently: I was testing diverts after switching broker from ActiveMQ to Artemis. I couldn't find the expected headers which contain original destination name; the reason was the wrong JMS client libraries. – Art Licis Dec 21 '17 at 11:34
  • yes there is something wrong with JMS client, Also there are no error logs throwing from JMS client so it's a lil complicated task for a dev to figure out the main issue. – Bhushan Uniyal Dec 22 '17 at 07:21