2017-03-15 21 views
0

Azureキューに接続してメッセージを消費するアプリケーションを作成しました。問題は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キューに接続するための設定コード。 Azure spring boot connectionタイムアウト例外

@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> 

と私のURLは次のとおりです。 amqps://user:<password>@myqueue2.servicebus.windows.net

私の質問は、アクティブな接続を維持するか、どのように例外の後にキューに再接続する方法です。ありがとうございました。

答えて

0

Qpidの公式ドキュメントFailover Configuration optionsによると、接続が失われたときに自動的に再接続するために、フェールオーバーのURIを使用してQpidのフェイルオーバー機能を有効にしてください。

関連する問題