The ODE Mongo Logger
module listens for messages on a specified Kafka topic and writes them to a MongoDB database. The module is designed to be deployed as a Docker container and is part of the WyoCV Suite of applications.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Dependency | Direct/Indirect | Link |
---|---|---|
Kafka | Direct | Kafka |
MongoDB Server | Direct | MongoDB |
- Java is provided by the dev container's base image.
- Maven is provided by the dev container's base image.
The following instructions are intended to be executed from the root directory of the WyoCV project:
-
Reopen the project in the provided dev container by clicking on the blue button in the bottom left corner of the window and selecting "Reopen in Container". If Docker isn't running, start it and try again.
-
Open a terminal in the dev container by clicking on the
Terminal
menu and selectingNew Terminal
-
Compile the project by running the following command:
mvn clean package -DskipTests -pl cv-data-service-library -pl ode-mongo-logger
-
Reopen the project locally by clicking on the blue button in the bottom left corner of the window and selecting "Reopen Folder Locally"
-
Move the compiled JAR to the root directory of the module:
Linux:
mv ./ode-mongo-logger/target/ode-mongo-logger-x.x.x-SNAPSHOT.jar ./ode-mongo-logger/
Windows:
move .\ode-mongo-logger\target\ode-mongo-logger-x.x.x-SNAPSHOT.jar .\ode-mongo-logger\
Replace
x.x.x
with the version number of the JAR file. If a JAR file already exists in theode-mongo-logger
directory, you may need to delete it first. -
Copy the sample.env to .env:
Linux:
cp sample.env .env
Windows:
copy sample.env .env
-
Update the .env file with the appropriate values. See the Configuration section for more information.
-
Verify that the necessary dependencies are running and accessible at the addresses specified in the
.env
file. -
Build & run the docker container with the following command:
docker compose up -d --build tim_logger_mongo
-
View the logs with the following command:
docker compose logs -f tim_logger_mongo
To stop viewing the logs, press
Ctrl+C
. -
To stop the container, run the following command:
docker compose down
A basic development environment file has been included (/resource/application-dev.properties) and is used when debugging via the ODE Mongo Logger (Launch)
configuration. This configuration is intended to be used with the provided dev container.
To run the application using the provided launch configuration, follow these steps:
- Update the
application.properties
file with the appropriate values. See the Configuration section for more information. - Verify that the necessary dependencies are running and accessible at the addresses specified in the
application.properties
file. - Open the project in the provided dev container by clicking on the blue button in the bottom left corner of the window and selecting "Reopen in Container"
- Open the Run and Debug sidebar by clicking on the icon on the left side of the window or by pressing
Ctrl+Shift+D
- Click on down arrow next to the gear icon in the top right corner of the sidebar
- Select the
ODE Mongo Logger (Launch)
configuration from the dropdown menu - Click the green play button to start the application
This application is deployed using Docker, and is part of the larger WyoCVApplication suite. The associated Dockerfile is configured for the development ODE environment. See the main README for the project and associated docker-compose, and sample.env file for further deployment configurations.
SOME OF THESE PROPERTIES ARE SENSITIVE. DO NOT PUBLISH THEM TO VERSION CONTROL
You may configure these values in ode-mongo-logger/src/main/resources/application.properties
or by editing them in the sample.env
file at the project root.
IMPORTANT When using the env file method, you must rename or duplicate the sample.env
file to .env
. If using the application.properties method, you must pass in the name of the environment to use with the --spring.profiles.active
parameter.
Environment Variable | Variable name(s) in sample.env |
Property name in application.properties |
Description | Example Value |
---|---|---|---|---|
MONGOLOGGER_DEPOSIT_TOPIC | TIM_TOPIC, BSM_TOPIC, DA_TOPIC | mongologger.depositTopic | The Kafka topic to listen for messages on | topic.OdeTimJson |
MONGOLOGGER_DEPOSIT_GROUP | TIM_GROUP_MONGO, BSM_GROUP_MONGO, DA_GROUP_MONGO | mongologger.depositGroup | The Kafka consumer group to use | logger_group_tim_dev_local |
MONGOLOGGER_HOSTNAME | MONGO_HOSTNAME | mongologger.hostname | The hostname of the machine that the mongo logger is running on | localhost |
MONGOLOGGER_MONGO_HOST | MONGO_HOST | mongologger.mongoHost | The hostname of the MongoDB server | localhost |
MONGOLOGGER_MONGO_DATABASE | MONGO_DATABASE | mongologger.mongoDatabase | The name of the MongoDB database to write to | wyo_cv |
MONGOLOGGER_MONGO_AUTH_DATABASE | MONGO_AUTH_DATABASE | mongologger.mongoAuthDatabase | The name of the MongoDB authentication database | admin |
MONGOLOGGER_MONGO_USERNAME | MONGO_USERNAME | mongologger.mongoUsername | The username to use to connect to MongoDB | admin |
MONGOLOGGER_MONGO_PASSWORD | MONGO_PASSWORD | mongologger.mongoPassword | The password to use to connect to MongoDB | password |
MONGOLOGGER_ALERT_ADDRESSES | MONGO_ALERT_ADDRESSES | mongologger.alertAddresses | The email addresses to send alerts to | test@gmail.com |
MONGOLOGGER_FROM_EMAIL | MONGO_FROM_EMAIL | mongologger.fromEmail | The email address to send alerts from | test@gmail.com |
MONGOLOGGER_ENVIRONMENT_NAME | ENVIRONMENT_NAME | mongologger.environmentName | The name of the environment the logger is running in | dev |
MONGOLOGGER_MAIL_HOST | MAIL_HOST | mongologger.mailHost | The hostname of the SMTP server to use for sending alerts | smtp.gmail.com |
MONGOLOGGER_MAIL_PORT | MAIL_PORT | mongologger.mailPort | The port of the SMTP server to use for sending alerts | 587 |
- Reopen project in provided dev container
- Run the following command to execute unit tests:
mvn clean test -p cv-data-service-library -p ode-mongo-logger
This will build the library that the module depends on and run the unit tests for the module (as well as the library).
This module requires a Kafka broker and MongoDB server to be running. The module listens for messages on a specified Kafka topic and writes them to a MongoDB database.
Once configured and running, no further action is required.