简体   繁体   English

Azure Spring Boot连接超时异常

[英]Azure spring boot connection Timeout Exception

I have created an application which connects to Azure queue and consumes the message. 我创建了一个连接到Azure队列并使用该消息的应用程序。 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. 问题是240000 ms连接自动关闭后,出现异常"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我的配置代码为连接到Azure队列。

    @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 和我的pom.xml文件

    <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 而我的网址是: 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. 请帮忙谢谢。

根据有关故障转移配置选项的Qpid官方文档,请尝试使用URI进行故障转移以启用Qpid的故障转移功能,以在连接断开时自动重新连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM