Spring Cloud DataFlow Error: "AmqpConnectException: java.net.ConnectException: Connection refused"
search cancel

Spring Cloud DataFlow Error: "AmqpConnectException: java.net.ConnectException: Connection refused"

book

Article ID: 297144

calendar_today

Updated On:

Products

Support Only for Spring

Issue/Introduction

Symptoms:

Spring Cloud DataFlow fails with the following error when you try to deploy a stream

2016-10-19 11:47:47.159 INFO 65071 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer :
Tomcat started on port(s): 33910 (http) 2016-10-19 11:47:47.163 INFO 65071 --- [ main] o.s.c.s.a.l.s.r.LogSinkRabbitApplication : 
Started LogSinkRabbitApplication in 12.202 seconds (JVM running for 13.157) 2016-10-19 11:47:52.090 WARN 65071 --- 
[http.httptest-1] o.s.a.r.l.SimpleMessageListenerContainer : 
Consumer raised exception, processing can restart if the connection factory supports it. 
Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused
 

Environment


Cause

This is usually caused if a RabbitMQ service was not bound properly to the application.

Resolution

1. If you have not created a RabbitMQ service, create one using

cf create-service cloudamqp lemur rabbit

2. You have to pass "rabbit" service name via SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES. The environment variable SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES k/v pair from Spring Cloud Data Flow perspective, but when SCDF deploys the apps, it iterates over the list and binds the named serviced to the apps automatically

cf set-env dataflow-server SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES rabbit

If you are not running SCDF on Pivotal Cloud Foundry or locally, set the environment variable; this would depend on what OS you are using

export SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES=rabbit


In a nutshell, whenever you deploy a stream successfully (With apps in it), each one of the app is looked up and resolved from the configured maven repository and it gets cached. So, every new app goes through this cycle at least once and then it gets cached until there's a new version of the same app artifact.

It does take 1-2 minutes with the first stream deployment attempts and when you repeat the deploys, it will be faster. When this happens, the stream status changes from failed to deploying to deployed.

For more information on deploying modules on cloud foundry using SCDF, see here .