Description: This microservice manages the voyages for each ship. A voyage consist of carrying a limited amount of goods from a source port to a destination port being the goods carried by a uniquely identified ship on a specific date. All those attributes make a voyage unique and these voyages are managed by this microservice. Voyages microservice will then be responsible to allocate a voyage to an order based on where this order needs to be carried from and to, the window time the goods need to be carried within and the amount of goods to be carried. Written in NodeJS, this microservice assigns a voyage to an order (and manage the remaining capacity on the ship making such voyage) if any suitable voyage is found and emit the consequent VoyageAssigned Event or will otherwise emit a VoyageNotFound Event.
Github repository: refarch-kc-ms
Kafka topics consumed from:
Kafka topics produced to:
Events reacted to:
- Order Created Event
- Order Reject Event
- Order Cancel Event
- Container Allocated Event
- Container Not Found Event
EDA Patterns implemented:
Appsody will build the application by pulling the contents of the Appsody Stack it is based on and then performing the local application build inside the containerized environment:
appsody build -t <yournamespace>/kcontainer-voyages-ms[:tag] [--push]
- You can optionally specify a container tag. If left blank,
latestwill be used.
- You can optionally supply the
--pushflag to automatically push the built image to specified remote repository.
Performing an Appsody build will update the
app-deploy.yaml file in the same directory with current information for the application image, labels, and annotations fields.
The following deployment parameters are defined in the
|KAFKA_BROKERS||YES||Comma-separated list of Kafka brokers to connect to|
|KAFKA_APIKEY||NO||API Key used to connect to SASL-secured Kafka brokers. This is required when connecting to IBM Event Streams clusters.|
|CERTS_ENABLED||NO||Required to be set to |
|CERTS_PATH||NO||The local path to the required certifcate file when connecting to IBM Event Streams on CP4I. See Volume Mounts below.|
|ORDER_TOPIC||YES||The topic name used for communication relating to the orders entity.|
The Voyage Management microservice requires up to one file to be injected at runtime for proper operation. As noted in the
CERTS_PATH parameter above, these files are SSL-based certificates which are required to verfiy the identity of the external service when calling it. These files are provided as
--docker-options "-v host-src:container-dest ..." when running the microservice locally and as a Volume Mount when running the microservice on a Kubernetes cluster.
CERTS_PATH parameter is documented in the Event Streams Certificates section of the Prerequisites page. The Appsody run command should include a parameter similar to
-v /Users/myuser/Downloads/es-cert.pem:/etc/ssl/certs/kcontainer/es-cert.pem in its
--docker-options string to run this microservice locally.
appsody run --docker-options "-v /Users/myuser/Downloads/es-cert.pem:/etc/ssl/certs/kcontainer/es-cert.pem " ...
When running the microservice locally, you must specify all the required deployment parameters from above as environment variables via the
--docker-options flag being passed in from the Appsody CLI command.
appsody run --docker-options "-e KAFKA_BROKERS=remotebroker1:9092,remotebroker2:9092 -e ORDER_TOPIC=orders -v /Users/myuser/Downloads/es-cert.pem:/etc/ssl/certs/kcontainer/es-cert.jks" ...
The Appsody Operator is a required prerequisite for deploying the microservice to a remote Kubernetes or OpenShift cluster.
To deploy the microservice to a remote cluster:
appsody deploy <yournamespace>/kcontainer-voyages-ms[:tag] --no-build
- You can omit the
--no-buildflag to have Appsody perform a build before deploying the application.
- Note: Performing a build at deploy time requires specifying the absolute container reference path, as well as the
- The neccesary deployment parameter information will be read from the
app-deploy.yamlfile in the same directory.