-
Notifications
You must be signed in to change notification settings - Fork 31
JetStream archetype
This archtype will create a sample app. The App will have a InboundMessaging channel, Sample Processor and OutboundMessaging Channel. It also generates Dockerfile and script for start the app inside the docker container.
mvn archetype:generate -DarchetypeGroupId=com.ebay.jetstream.archetype -DarchetypeArtifactId=simpleapp -DarchetypeVersion=4.1.0
It is a maven project, just run: mvn clean install
Just run docker build on the project folder: sudo docker build -t <username>/appname .
sudo docker run -i -p 0.0.0.0:9999:9999 --link zkserver:zkserver --link mongoserver:mongoserver -t <username>/appname
Jetstream messaging require the consumer listen on the tcp port, if all containers on one host, it will be no issue. Or each host just host one container and use --net=host to bind all ports on the host, it will also no any issues.
But when deploy multiple apps on multiple hosts, and each host has multiple containers, it require to assign the port carefully. First all apps should use --net=host mode, and then it assign port by using ENVIRONMENT VARIABLE。 Jetstream will have three type ports:
- JETSTREAM_REST_BASEPORT - This is the start port used by http server, only when the app need use the rest inbound channel, inside the spring xml file, should use expression to set the rest port from the start port and plus an offset, by default it is 8080, for example - #{T(java.lang.Integer).parseInt(systemProperties['jetstream.rest.baseport'] ?: '8080') + 0}
- JETSTREAM_CONTEXT_BASEPORT - This is the start port used by jetstream messaging, inside the spring message context xml file, should use expression to set the messaging port from the start port and plus an offset, by default it is 15590, for example - #{T(java.lang.Integer).parseInt(systemProperties['jetstream.context.baseport'] ?: '15590') + 0}
- JETSTREAM_APP_PORT - This is only one port used for management, just use -e JETSTREAM_APP_PORT=1234 to override the port, by default is 9999
The app require the zookeeper, zookeeper must be ready before run the app, and by default, it will use 127.0.0.1:2181 to connect to zookeeper, and it can be overrided by the system property.
The app is a spring based app, and the main class is com.ebay.jetstream.application.JetstreamApplication, it require below command line options:
- -n appname - Indicate the app name
- -cv 1.0 - Indicate the config version
- -p 9999 - Indicate the http port of the monitoring page
And need configure below ENVIRONMENT VARIABLE:
- JETSTREAM_HOME - point to the buildsrc folder, this is mandatory
- MONGO_HOME - the mongo url for configuration, this is optional, if it is not available, it will use local spring file.
Below system property can be overrided:
- jetstream.runtime.zkserver.host - For zk server
- jetstream.runtime.zkserver.port - For zk server port
- jetstream.runtime.netmask - Choose which NIC to be used.
The app will be assembled as a tar.gz file, just unzip it and reference the start.sh which used for docker. Change the start.sh to set correct ENVIRONMENT VARIABLE. then run the start.sh.