I have created an application which connects to Azure queue and consumes the message. Issue is after 240000 ms connection is closed automatically and I am getting the exception "org.apache.qpid.amqp_1_0.jms.MessageConsumerException: The connection was inactive for more than the allowed 240000 milliseconds and is closed by container
.
PFB My configuration code to connect to Azure queue.
@Bean
public ConnectionFactory jmsConnectionFactory() {
CachingConnectionFactory cachingConnectionFactory = null;
try {
cachingConnectionFactory = new CachingConnectionFactory(ConnectionFactoryImpl.createFromURL(url));
cachingConnectionFactory.setReconnectOnException(true);
cachingConnectionFactory.setClientId(applicationName);
} catch (MalformedURLException e) {
logger.error("Exception", e);
}
return cachingConnectionFactory;
}
@Bean
public MessageListenerContainer getContainer() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(jmsConnectionFactory());
container.setDestinationName(queueName);
container.setMessageListener(messageConsumer);
container.setConcurrency(concurrency);
return container;
}
and my pom.xml file
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
<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>
</dependencies>
and my url is:
amqps://user:<password>@myqueue2.servicebus.windows.net
My question is how to keep the connection active or how to reconnect to queue after exception. Please help thanks.