de.wuespace.telestion.extension.mongodb 0.3.0 Latest version
Install 1/2: Add this to pom.xml:
Learn more about Maven or Gradle
<dependency>
<groupId>de.wuespace.telestion.extension</groupId>
<artifactId>mongodb</artifactId>
<version>0.3.0</version>
</dependency>
Install 2/2: Run via command line
$ mvn install
About this package
A MongoDB connector for the Telestion backend.
First, add the extension package registry to your gradle repositories:
repositories {
maven {
name = "GitHubMongoDB"
url = uri("https://maven.pkg.github.com/wuespace/telestion-extension-mongodb/")
credentials {
username = System.getenv("GITHUB_ACTOR") == null ? GITHUB_ACTOR : System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN") == null ? GITHUB_TOKEN : System.getenv("GITHUB_TOKEN")
}
}
}
Next, add the extension to the project dependency list:
dependencies {
// ...
implementation 'de.wuespace.telestion.extension:mongodb:0.1.0'
// ...
}
And synchronize gradle.
Finished!
The extension provides different verticles, that you can use and set up in your project config.json
.
You will need at least the
MongoDatabaseService
verticle to communicate with the Mongo-Database.
A really simple configuration could look like:
{
"org.telestion.configuration": {
"app_name": "Basic Example",
"verticles": [
{
"name": "Mongo Database Service",
"verticle": "de.wuespace.telestion.extension.mongodb.MongoDatabaseService",
"magnitude": 1,
"config": {
"host": "mongodb"
}
}
]
}
}
with the host
property specifying the hostname or ip address of the host machine running the mongo database.
Now, you can extend your configuration to store and request data from the database.
You can use the
DataListener
verticle to listen to specific eventbus addresses and insert incoming messages into the database.
For example:
{
"org.telestion.configuration": {
"app_name": "Basic Example",
"verticles": [
{
"name": "Data Listener",
"verticle": "de.wuespace.telestion.extension.mongodb.DataListener",
"magnitude": 1,
"config": {
"listeningAddresses": [
"example-data"
]
}
},
{
"name": "Mongo Database Service",
"verticle": "de.wuespace.telestion.extension.mongodb.MongoDatabaseService",
"magnitude": 1,
"config": {
"host": "mongodb"
}
}
]
}
}
This configuration deploys a verticle which listens on the eventbus address example-data
and stores all incoming messages into the registered mongo database.
Every message type obtains its own collection in mongo.
To access the collections, use the full classname of the message type.
To extract data in periodic intervals, you can use the
PeriodicDataAggregator
verticle. It requests data in regular intervals,
combines them in a predefined format into one message
and sends it on the specified eventbus address.
For example:
{
"org.telestion.configuration": {
"app_name": "Basic Example",
"verticles": [
{
"name": "Mongo Database Service",
"verticle": "de.wuespace.telestion.extension.mongodb.MongoDatabaseService",
"magnitude": 1,
"config": {
"host": "mongodb"
}
},
{
"name": "Periodic Data Aggregator",
"verticle": "de.wuespace.telestion.extension.mongodb.PeriodicDataAggregator",
"magnitude": 1,
"config": {
"collection": "de.wuespace.telestion.project.daedalus2.messages.SystemT",
"field": "imu.acc.x",
"rate": 10,
"outAddress": "aggregated-imu.acc.x"
}
}
]
}
}
Here the PeriodicDataAggregator
looks for a collection storing the SystemT
message type
and tries to extract the imu.acc.x
property which can be deeply nested.
After it gathered all required information, it publishes the data onto the aggregated-imu.acc.x
eventbus address.
You can configure the aggregation rate via the rate
property. The rate is represented as aggregations per second.
If you use our Project Template,
you can easily add MongoDB to your build and deploy pipeline.
Open the docker-compose.yml
in the application
folder and add the mongodb
service:
version: "3.9"
services:
mongodb:
# most recent and stable version off mongodb
image: "mongo:4"
profiles: ["devel-native", "devel-docker", "prod"]
restart: always
ports:
# passthrough mongodb listen port to host for debugging
- "127.0.0.1:27017:27017"
volumes:
# store database data for a later restart
- type: volume
source: mongodb-data
target: "/data/db"
# environment:
# # mongodb authentication
# MONGO_INITDB_ROOT_USERNAME: 'root'
# MONGO_INITDB_ROOT_PASSWORD: '12345'
# bind to open ip to allow incoming connections from other network devices
command: "--bind_ip 0.0.0.0"
telestion-devel:
image: "telestion-devel"
profiles: ["devel-docker"]
# ...
Do not forget to also update the production.yml
:
version: "3.7"
services:
mongodb:
# most recent and stable version off mongodb
image: "mongo:4"
restart: always
ports:
# passthrough mongodb listen port to host for debugging
- "127.0.0.1:27017:27017"
volumes:
# store database data for a later restart
- type: volume
source: mongodb-data
target: "/data/db"
# environment:
# # mongodb authentication
# MONGO_INITDB_ROOT_USERNAME: 'root'
# MONGO_INITDB_ROOT_PASSWORD: '12345'
# bind to open ip to allow incoming connections from other network devices
command: "--bind_ip 0.0.0.0"
telestion:
image: "ghcr.io/wuespace/telestion-project-daedalus2:latest"
restart: always
# ...
For the documentation on contributing to this repository,
please take a look at the Contributing Guidelines.
This is part of Telestion, a project by WüSpace e.V..
Details
- wuespace
- July 31, 2021
- 7 dependencies
- MIT License
Assets
- mongodb-0.3.0-sources.jar.sha512
- mongodb-0.3.0-sources.jar.sha256
- mongodb-0.3.0-sources.jar.md5
- mongodb-0.3.0-sources.jar.sha1
- mongodb-0.3.0-sources.jar
- mongodb-0.3.0-javadoc.jar.sha512
- mongodb-0.3.0-javadoc.jar.sha256
- mongodb-0.3.0-javadoc.jar.md5
- mongodb-0.3.0-javadoc.jar.sha1
- mongodb-0.3.0-javadoc.jar
- mongodb-0.3.0.module.sha512
- mongodb-0.3.0.module.sha256
- mongodb-0.3.0.module.md5
- mongodb-0.3.0.module.sha1
- mongodb-0.3.0.module
- mongodb-0.3.0.pom.sha512
- mongodb-0.3.0.pom.sha256
- mongodb-0.3.0.pom.md5
- mongodb-0.3.0.pom.sha1
- mongodb-0.3.0.pom
- mongodb-0.3.0.jar.sha512
- mongodb-0.3.0.jar.sha256
- mongodb-0.3.0.jar.md5
- mongodb-0.3.0.jar.sha1
- mongodb-0.3.0.jar
Download activity
- Total downloads 12
- Last 30 days 0
- Last week 0
- Today 0