Skip to content

JetStream archetype

Xinglang Wang edited this page Aug 6, 2015 · 5 revisions

Introduction

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.

Create a new app

mvn archetype:generate -DarchetypeGroupId=com.ebay.jetstream.archetype -DarchetypeArtifactId=simpleapp -DarchetypeVersion=4.1.0

Build and assemble the app

It is a maven project, just run: mvn clean install

Dockerize the app

Just run docker build on the project folder: sudo docker build -t <username>/appname .

Run the docker container

sudo docker run -i -p 0.0.0.0:9999:9999 --link zkserver:zkserver --link mongoserver:mongoserver -t <username>/appname

Port assignment

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:

  1. 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}
  2. 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}
  3. 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

Run it in IDE

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:

  1. -n appname - Indicate the app name
  2. -cv 1.0 - Indicate the config version
  3. -p 9999 - Indicate the http port of the monitoring page

And need configure below ENVIRONMENT VARIABLE:

  1. JETSTREAM_HOME - point to the buildsrc folder, this is mandatory
  2. 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:

  1. jetstream.runtime.zkserver.host - For zk server
  2. jetstream.runtime.zkserver.port - For zk server port
  3. jetstream.runtime.netmask - Choose which NIC to be used.

Run it without docker

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.

Next: Creating Custom Channels And Processors

Clone this wiki locally