【问题标题】:Create Stream on startup/by script在启动时/通过脚本创建流
【发布时间】:2014-07-08 10:36:19
【问题描述】:

我希望在 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),并且管道 (|) 也造成了一些麻烦。

谢谢

【问题讨论】:

    标签: spring-xd


    【解决方案1】:

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

    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 调用

    【讨论】:

    • 不确定它最近是否改变,但参数实际上是--cmdfile(全部小写)
    【解决方案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 接受以逗号分隔的主机:端口对字符串

    【讨论】:

      猜你喜欢
      • 2020-04-09
      • 1970-01-01
      • 2021-08-26
      • 2017-04-07
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-05
      • 2012-05-04
      相关资源
      最近更新 更多