2017-03-15 86 views
0

我創建了一個連接到Azure隊列並使用該消息的應用程序。問題是240000毫秒連接自動關閉後,我收到異常"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隊列。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; 
} 

和我的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> 

和我的網址是: amqps://user:<password>@myqueue2.servicebus.windows.net

我的問題是如何保持連接活動或如何重新連接異常後排隊。請幫忙謝謝。

回答

0

根據關於Failover Configuration options的Qpid官方文檔,請嘗試使用用於故障轉移的URI來啓用Qpid的故障轉移功能,以便在連接丟失時自動重新連接。