0

我希望在 spring-xd 容器启动时创建一个流,而不必通过 xd-shell 手动输入它。我想要; 1. 启动 xd-singlenode(通过 bash 调用) 2.http --port=8080 | file在容器启动后部署预先创建的流定义(例如)

我知道有一个 url 可以调用 ( curl -POST http://127.0.0.1:9393/streams?name=mystream&definition=http|file),但是我在指定额外的配置时遇到了麻烦 (比如--port=8080) 并且管道 ( |) 也造成了一些麻烦。

谢谢

4

2 回答 2

2

另请查看https://github.com/spring-projects/spring-xd/tree/master/src/test/scripts您应该使用 curl 找到类似的示例。

另请注意,如果您使用外部 ZooKeeper 集成(即操作配置)运行,则无需执行此操作。ZK 会在重新启动时保留并恢复 XD 集群状态,因此在关闭时部署的任何流都将在启动时部署。单节点默认启动嵌入式 ZK 服务器,但可以配置为连接到外部服务器。例如,

export JAVA_OPTS=-Dzk.client.connect=localhost:2181

zk.client.connect 接受以逗号分隔的主机:端口对字符串

于 2014-07-08T14:10:10.880 回答
2

所以答案是您可以将参数(流配置)作为命令行参数传递

xd-shell --cmdFile [filename]

命令文件的内容是您将通过 shell 输入的内容,因此您将在哪里执行此操作

xd:>stream create --name teststream --definition "http | file" --deploy

你会写一个这样的文件

stream create --name teststream --definition "http | file" --deploy

举个例子;

xd-shell --cmdFile stream.cmd

所有这些都可以从 shell 调用

于 2014-07-08T12:43:02.197 回答