如何在spring云数据流中使用Rabbitmq binder

时间:2016-09-22 18:57:57

标签: rabbitmq spring-cloud spring-cloud-stream spring-cloud-dataflow

我有一个基于给定时间间隔启动任务的流。我想使用兔子绑定器,但我缺少提供rabbitmq代理属性的语法。有人可以帮助我。

Here is the steps and configuration I have.

 1. Imported apps using: app import --uri
    http//bitly/stream-applications-rabbit-maven
 2. Registered a task: app register --name task-sink --type sink --uri file://tasksink.jar
 3. Created stream: stream create foo --definition "triggertask --triggertask.uri=file://task-file.jar --trigger.cron-expression=10 | task-sink" 
 4. stream deploy foo --properties "spring.rabbitmq.host=myhost,         spring.rabbitmq.username=user,spring.rabbitmq.password=pass,     spring.rabbitmq.port=5672,spring.rabbitmq.virtual-host=XXX"

When both stream and runtime apps are deployed but I see error on logs saying connection could not be established.
I changed the properties syntax to "spring.cloud.stream.bindings.rabbitmq.host" also but same error.
I am not sure I am not using correct syntax here but below are some different behaviour when i run it on VPN and without VPN.

**Note**: 
Case 1: Both my machines (where SCDF is running and RabbitMQ broker) are in core network (VPN). Even if I run SCDF and RabbitMq on my local machine It does not work and says unable to resolve host.
Case 2: But when I run RabbitMQ and SCDF on my local machine (Not connected to VPN) then it works fine with "spring.rabbitmq.username=user" properties syntax.
Is there any setting which I need to change to connect to different host system?
Thanks in advance for help and suggestion.

1 个答案:

答案 0 :(得分:1)

spring.rabbitmq.host=myhost是正确的,但由于您将此传递给Spring Cloud Data Flow DSL中的应用程序,因此您需要在其前面加上应用程序名称,即app.triggertask.spring.rabbitmq.host等。其他应用程序也是如此。您有几个快捷方式,请参阅:

http://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#_passing_application_properties_when_deploying_a_stream

http://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#spring-cloud-dataflow-global-properties

了解详情。