Reputation: 2137
I'm looking to create a stream on startup of spring-xd container without having to manually enter it via xd-shell. I want to;
1. have xd-singlenode startup (invoked via bash)
2. have a pre-created stream definition (e.g. http --port=8080 | file
) deployed after the container starts up
I know there's a url to invoke (curl -POST http://127.0.0.1:9393/streams?name=mystream&definition=http|file
) but I'm having troubles with specifying additional configuration (like --port=8080
) and the pipe (|
) is causing some troubles too.
thanks
Upvotes: 0
Views: 1222
Reputation: 1723
Also have a look at https://github.com/spring-projects/spring-xd/tree/master/src/test/scripts You should find similar examples using curl.
Also note that if you are running with an external ZooKeeper ensemble, which is the operational configuration, you don't need to do this. ZK persists and restores the XD cluster state upon restart so any streams that were deployed at shutdown will be deployed at start up. Single node starts an embedded ZK server by default, but may be configured to connect to an external server. For example,
export JAVA_OPTS=-Dzk.client.connect=localhost:2181
zk.client.connect accepts a comma-delimited string of host:port pairs
Upvotes: 2
Reputation: 2137
so the answer is that you can pass arguments (stream configurations) as a command line argument
xd-shell --cmdFile [filename]
The contents of the command file are what you would enter via the shell so where you would do this
xd:>stream create --name teststream --definition "http | file" --deploy
you would write a file like this
stream create --name teststream --definition "http | file" --deploy
so as an example;
xd-shell --cmdFile stream.cmd
all of which can be invoked from a shell
Upvotes: 2