diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 025440f..123afa0 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -6,7 +6,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 11 uses: actions/setup-java@v3 with: @@ -18,7 +18,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload .jar file - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: pulsar-mqtt-gateway.jar path: target/pulsar-mqtt-gateway.jar @@ -28,9 +28,9 @@ jobs: # Run only on develop branch if: github.ref == 'refs/heads/develop' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Download .jar file - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: pulsar-mqtt-gateway.jar path: target @@ -47,9 +47,9 @@ jobs: # Run only for tagged commits if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Download .jar file - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: pulsar-mqtt-gateway.jar path: target diff --git a/Dockerfile b/Dockerfile index bde91d3..68ff827 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,4 @@ FROM eclipse-temurin:11-alpine RUN apk add --no-cache curl ADD target/pulsar-mqtt-gateway.jar /usr/app/pulsar-mqtt-gateway.jar -ENTRYPOINT ["java", "-jar", "/usr/app/pulsar-mqtt-gateway.jar"] +ENTRYPOINT ["java", "-XX:InitialRAMPercentage=10.0", "-XX:MaxRAMPercentage=95.0", "-jar", "/usr/app/pulsar-mqtt-gateway.jar"] diff --git a/README.md b/README.md index c548fc2..db37826 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# pulsar-mqtt-gateway [![Test and create Docker image](https://github.com/HSLdevcom/pulsar-mqtt-gateway/actions/workflows/test-and-build.yml/badge.svg)](https://github.com/HSLdevcom/pulsar-mqtt-gateway/actions/workflows/test-and-build.yml) + ## Description Application for publishing Pulsar messages to MQTT. The application doesn't care about @@ -9,13 +11,13 @@ the data content, it only publishes the binary message as-is. This project depends on [transitdata-common](https://github.com/HSLdevcom/transitdata-common) project. -Either use released versions from public maven repository or build your own and install to local maven repository: - - ```cd transitdata-common && mvn install``` +Either use released versions from the public GitHub Packages repository (Maven) or build your own and install to local Maven repository: +- `cd transitdata-common && mvn install` ### Locally -- ```mvn compile``` -- ```mvn package``` +- `mvn compile` +- `mvn package` ### Docker image @@ -24,22 +26,19 @@ Either use released versions from public maven repository or build your own and ## Running -Requirements: -- Pulsar Cluster - - By default uses localhost, override host in PULSAR_HOST if needed. - - Tip: f.ex if running inside Docker in OSX set `PULSAR_HOST=host.docker.internal` to connect to the parent machine - - You can use [this script](https://github.com/HSLdevcom/transitdata/blob/master/bin/pulsar/pulsar-up.sh) to launch it as Docker container -- Connection to an external MQTT server. - - Configure username and password via files - - Set filepath for username via env variable FILEPATH_USERNAME_SECRET, default is `/run/secrets/mqtt_broker_username` - - Set filepath for password via env variable FILEPATH_PASSWORD_SECRET, default is `/run/secrets/mqtt_broker_password` - - Mandatory: Set mqtt-topic via env variable MQTT_TOPIC - - -All other configuration options are configured in the [config file](src/main/resources/environment.conf) -which can also be configured externally via env variable CONFIG_PATH +### Dependencies -Launch Docker container with +* Pulsar +* Connection to a MQTT broker -```docker-compose -f compose-config-file.yml up ``` +### Environment variables +* `MQTT_HAS_AUTHENTICATION`: whether the MQTT broker uses authentication +* `FILEPATH_USERNAME_SECRET`: path to the file containing the username, default is `/run/secrets/mqtt_broker_username` +* `FILEPATH_PASSWORD_SECRET`: path to the file containing the password, default is `/run/secrets/mqtt_broker_password` +* `MQTT_BROKER_HOST`: URL of the MQTT broker +* `MQTT_TOPIC`: MQTT topic where to publish messages +* `MQTT_MAX_INFLIGHT`: maximum amount of MQTT messages in-flight +* `MQTT_CLIENT_ID`: MQTT client ID +* `MQTT_RETAIN_MESSAGE`: whether to send MQTT messages with retained flag +* `MQTT_KEEP_ALIVE_INTERVAL`: interval for MQTT keep-alive, in seconds diff --git a/pom.xml b/pom.xml index ff8cb19..4600ca6 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ UTF-8 11 11 - 1.3.29 + 1.5.4 1.2.5 @@ -52,7 +52,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.1 + 3.4.1 @@ -96,7 +96,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.11.0 11 11