2

I am creating consumer using qpid amqp-1-0-client and related jars to connect to Azure service bus. I am able to connect to Azure queue and receive messages, but the problem is I am receiving same message multiple times from queue eventhough i acknowledged it before processing the message. Also most of the times my messages are moved into DLQ.

For Example if i have 500 messages in queue, my onMessage() method which overrides MessageListener.onMessage() is getting executed for more than 500 times. and almost 200 messages are pushed into DLQ. I am reading message from queue and storing it in database. These numbers are not same always. For reading and storing a message in DB my application is taking 600ms. PFB My code which has configurations for connecting to Azure

@Configuration
public class AzureConfiguration {
@Bean
public ConnectionFactory jmsConnectionFactory() {
    CachingConnectionFactory cachingConnectionFactory = null;
    try {
        ConnectionFactoryImpl a = ConnectionFactoryImpl.createFromURL(url);
        a.setMaxPrefetch(0);
        a.setSyncPublish(true);
        cachingConnectionFactory = new CachingConnectionFactory(a);
        cachingConnectionFactory.setReconnectOnException(true);
        cachingConnectionFactory.setClientId(applicationName);
        exceptionListener.setCachedConnFactory(cachingConnectionFactory);
    } catch (MalformedURLException e) {
    }
    return cachingConnectionFactory;
}
@Bean
public MessageListenerContainer getContainer() {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(jmsConnectionFactory());
    container.setDestinationName(queueName);
    container.setMessageListener(messageConsumer);
    container.setConcurrency(concurrency);
    exceptionListener.setContainer(container);
    container.setExceptionListener(exceptionListener);
    container.setAutoStartup(true);
    container.setSessionAcknowledgeMode(2);
    return container;
}

}

and my dependencies: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.5</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jms_1.1_spec</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.apache.qpid</groupId> <artifactId>qpid-amqp-1-0-client</artifactId> <version>0.30</version> </dependency> <dependency> <groupId>org.apache.qpid</groupId> <artifactId>qpid-amqp-1-0-client-jms</artifactId> <version>0.30</version> </dependency> <dependency> <groupId>org.apache.qpid</groupId> <artifactId>qpid-amqp-1-0-common</artifactId> <version>0.30</version> </dependency>

Please help.

anonymous
  • 483
  • 2
  • 8
  • 24

1 Answers1

0

You are using the legacy AMQP 1.0 JMS client that is not supported and does not implement the AMQP JMS mapping specification as it currently stands. That it doesn't work is not terribly surprising. You should have better luck using the newer and now only support AMQP JMS client from Qpid which you can get here.

<dependency>
  <groupId>org.apache.qpid</groupId>
  <artifactId>qpid-jms-client</artifactId>
  <version>0.21.0</version>
</dependency>
Tim Bish
  • 17,475
  • 4
  • 32
  • 42