如何在 Spring Cloud 数据流中使用 Rabbitmq binder
Posted
技术标签:
【中文标题】如何在 Spring Cloud 数据流中使用 Rabbitmq binder【英文标题】:How to use Rabbitmq binder in spring cloud dataflow stream 【发布时间】:2017-01-31 11:54:24 【问题描述】:我有一个基于给定时间间隔启动任务的流。我想与它一起使用rabbit binder,但我缺少提供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 *** and without ***.
**Note**:
Case 1: Both my machines (where SCDF is running and RabbitMQ broker) are in core network (***). 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 ***) 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】: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
了解详情。
【讨论】:
非常感谢马吕斯。是的,我错过了应用程序。应用程序名称。现在我的应用可以连接到主机了。以上是关于如何在 Spring Cloud 数据流中使用 Rabbitmq binder的主要内容,如果未能解决你的问题,请参考以下文章
spring cloud数据流API.1.7.3中如何使用dataflowtemplate
如何在 Spring Cloud 数据流中使用 Rabbitmq binder
spring-cloud-starter-eureka-server 和 spring-cloud-starter-netflix-eureka-server的区别
如何在 Google Cloud Function 上的 Spring Cloud 函数中获取 Pub/Sub 事件的元数据
随手记录关于spring-cloud-starter-eureka-server 和 spring-cloud-starter-netflix-eureka-server