2017-05-24 10 views
1

私はHerokuプラットフォームでCloudAMQPと連携するSpringを取得しようとしています。 は、これが私の状況です:"Unknown Host Exception"を与えるHerokuのSpring&CloudAMQP

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:rabbit="http://www.springframework.org/schema/rabbit" 
     xsi:schemaLocation="http://www.springframework.org/schema/rabbit 
      http://www.springframework.org/schema/rabbit/spring-rabbit.xsd 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context.xsd"> 

    <rabbit:connection-factory id="connectionFactory" host="#{systemEnvironment['CLOUDAMQP_URL']}"/> 

    <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" 
     exchange="myExchange" routing-key="foo.bar"/> 

    <rabbit:admin connection-factory="connectionFactory" /> 

    <rabbit:queue name="myQueue" /> 

    <rabbit:topic-exchange name="myExchange"> 
     <rabbit:bindings> 
      <rabbit:binding queue="myQueue" pattern="foo.*" /> 
     </rabbit:bindings> 
    </rabbit:topic-exchange> 


    <rabbit:listener-container connection-factory="connectionFactory" 
     error-handler="exHandler"> 

     <rabbit:listener ref="foo" method="listen" queue-names="myQueue" /> 
    </rabbit:listener-container> 

    <bean id="foo" class="Foo" /> 
    <bean id="exHandler" class="BackgroundRejectingErrorHandler" /> 
</beans> 

しかし、私は奇妙な何かに実行しています:ローカルそれはローカルホスト= CLOUDAMQP_URLを渡して、完全に正常に動作しますが、Herokuの上で、私は次の例外を取得:

2017-05-24T13:56:00.062653+00:00 app[worker.1]: org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: ${HEROKU_CLOUDAMQP_URL}: invalid IPv6 address 
2017-05-24T13:56:00.062655+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) 
2017-05-24T13:56:00.062655+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:367) 
2017-05-24T13:56:00.062656+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:565) 
2017-05-24T13:56:00.062659+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430) 
2017-05-24T13:56:00.062660+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411) 
2017-05-24T13:56:00.062661+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1387) 
2017-05-24T13:56:00.062661+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:336) 
2017-05-24T13:56:00.062662+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:1136) 
2017-05-24T13:56:00.062663+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1387) 
2017-05-24T13:56:00.062664+00:00 app[worker.1]:  at java.lang.Thread.run(Thread.java:745) 

I

amqp://$user:[email protected]/VHOST 

のフルスタックトレース:

の形で実際の接続文字列と$ {HEROKU_CLOUDAMQP_URLを}に置き換え
2017-05-24T13:55:59.175707+00:00 app[worker.1]: INFO: Refreshing 
org[email protected]65b3120a: startup date [Wed May 24 13:55:59 UTC 2017]; root of context hierarchy 
2017-05-24T13:55:59.238539+00:00 app[worker.1]: May 24, 2017 1:55:59 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
2017-05-24T13:55:59.238556+00:00 app[worker.1]: INFO: Loading XML bean definitions from class path resource [backgroundContext.xml] 
2017-05-24T13:55:59.379090+00:00 app[worker.1]: May 24, 2017 1:55:59 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
2017-05-24T13:55:59.379102+00:00 app[worker.1]: INFO: Loading XML bean definitions from class path resource [herokuApiBeans.xml] 
2017-05-24T13:55:59.462609+00:00 app[worker.1]: May 24, 2017 1:55:59 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
2017-05-24T13:55:59.462612+00:00 app[worker.1]: INFO: Loading XML bean definitions from class path resource [backgroundBeans.xml] 
2017-05-24T13:55:59.570041+00:00 app[worker.1]: May 24, 2017 1:55:59 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
2017-05-24T13:55:59.570056+00:00 app[worker.1]: INFO: Loading XML bean definitions from class path resource [rabbitMqConfig.xml] 
2017-05-24T13:55:59.792582+00:00 app[worker.1]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
2017-05-24T13:55:59.792623+00:00 app[worker.1]: SLF4J: Defaulting to no-operation (NOP) logger implementation 
2017-05-24T13:55:59.792726+00:00 app[worker.1]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
2017-05-24T13:56:00.046847+00:00 app[worker.1]: May 24, 2017 1:56:00 PM org.springframework.context.support.DefaultLifecycleProcessor start 
2017-05-24T13:56:00.046865+00:00 app[worker.1]: INFO: Starting beans in phase -2147482648 
2017-05-24T13:56:00.047727+00:00 app[worker.1]: May 24, 2017 1:56:00 PM org.springframework.context.support.DefaultLifecycleProcessor start 
2017-05-24T13:56:00.047728+00:00 app[worker.1]: INFO: Starting beans in phase 2147483647 
2017-05-24T13:56:00.062649+00:00 app[worker.1]: May 24, 2017 1:56:00 PM org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer redeclareElementsIfNecessary 
2017-05-24T13:56:00.062652+00:00 app[worker.1]: SEVERE: Failed to check/redeclare auto-delete queue(s). 
2017-05-24T13:56:00.062653+00:00 app[worker.1]: org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: ${HEROKU_CLOUDAMQP_URL}: invalid IPv6 address 
2017-05-24T13:56:00.062655+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) 
2017-05-24T13:56:00.062655+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:367) 
2017-05-24T13:56:00.062656+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:565) 
2017-05-24T13:56:00.062659+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430) 
2017-05-24T13:56:00.062660+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411) 
2017-05-24T13:56:00.062661+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1387) 
2017-05-24T13:56:00.062661+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:336) 
2017-05-24T13:56:00.062662+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:1136) 
2017-05-24T13:56:00.062663+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1387) 
2017-05-24T13:56:00.062664+00:00 app[worker.1]:  at java.lang.Thread.run(Thread.java:745) 
2017-05-24T13:56:00.062665+00:00 app[worker.1]: Caused by: java.net.UnknownHostException: ${HEROKU_CLOUDAMQP_URL}: invalid IPv6 address 
2017-05-24T13:56:00.062665+00:00 app[worker.1]:  at java.net.InetAddress.getAllByName(InetAddress.java:1169) 
2017-05-24T13:56:00.062666+00:00 app[worker.1]:  at java.net.InetAddress.getAllByName(InetAddress.java:1126) 
2017-05-24T13:56:00.062667+00:00 app[worker.1]:  at com.rabbitmq.client.DnsRecordIpAddressResolver.resolveIpAddresses(DnsRecordIpAddressResolver.java:83) 
2017-05-24T13:56:00.062668+00:00 app[worker.1]:  at com.rabbitmq.client.DnsRecordIpAddressResolver.getAddresses(DnsRecordIpAddressResolver.java:73) 
2017-05-24T13:56:00.062669+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:903) 
2017-05-24T13:56:00.062670+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859) 
2017-05-24T13:56:00.062670+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1000) 
2017-05-24T13:56:00.062671+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:355) 
2017-05-24T13:56:00.062672+00:00 app[worker.1]:  ... 8 more 
2017-05-24T13:56:00.062673+00:00 app[worker.1]: 
2017-05-24T13:56:00.073827+00:00 app[worker.1]: Exception in thread "main" org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: ${HEROKU_CLOUDAMQP_URL}: invalid IPv6 address 
2017-05-24T13:56:00.073937+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) 
2017-05-24T13:56:00.074010+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:367) 
2017-05-24T13:56:00.074139+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:565) 
2017-05-24T13:56:00.074197+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430) 
2017-05-24T13:56:00.074258+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411) 
2017-05-24T13:56:00.074345+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:712) 
2017-05-24T13:56:00.074396+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:780) 
2017-05-24T13:56:00.074457+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:752) 
2017-05-24T13:56:00.074525+00:00 app[worker.1]:  at background.ApplicationContextBackground.main(ApplicationContextBackground.java:45) 
2017-05-24T13:56:00.074632+00:00 app[worker.1]: Caused by: java.net.UnknownHostException: ${HEROKU_CLOUDAMQP_URL}: invalid IPv6 address 
2017-05-24T13:56:00.074687+00:00 app[worker.1]:  at java.net.InetAddress.getAllByName(InetAddress.java:1169) 
2017-05-24T13:56:00.074738+00:00 app[worker.1]:  at java.net.InetAddress.getAllByName(InetAddress.java:1126) 
2017-05-24T13:56:00.074795+00:00 app[worker.1]:  at com.rabbitmq.client.DnsRecordIpAddressResolver.resolveIpAddresses(DnsRecordIpAddressResolver.java:83) 
2017-05-24T13:56:00.074842+00:00 app[worker.1]:  at com.rabbitmq.client.DnsRecordIpAddressResolver.getAddresses(DnsRecordIpAddressResolver.java:73) 
2017-05-24T13:56:00.074901+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:903) 
2017-05-24T13:56:00.074953+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859) 
2017-05-24T13:56:00.075016+00:00 app[worker.1]:  at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1000) 
2017-05-24T13:56:00.075092+00:00 app[worker.1]:  at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:355) 
2017-05-24T13:56:00.075159+00:00 app[worker.1]:  ... 7 more 

何か間違っていますか?

ありがとうございます。

答えて

1

固定されました。

もちろん、ウサギ:connection-factory - > HOST < - 完全なURIを処理することはできません。 そのため、すべてのパラメータを分割して順番に渡す必要があります。