Modifying the Container Configuration

You can further configure the connector container. You can either modify the provided sample or create a custom application.yml or application.properties file in the config directory containing the properties required for the connector.

To use the connector in a container:

Prerequisites

Using the Connector for MQTT with containers requires:

Getting Started Using Connectors With Containers

You cSecurityan run the connector in a container with the minimal configuration. Optionally, you can specify connecter services on the host or a health check. Perform the following steps to start the connector with a minimal configuration in a container:

  1. Create a directory called libs.

  2. Download the JAR files for the MQTT client and all its required dependencies and place them in the libs directory.

    To use the connector with ActiveMQ, download the activemq-client and its required dependencies from Maven Central.

  3. Create a directory called config.

  4. Create an application.yml or application.properties file in the config directory containing the properties needed for your connector. For an example of an configuration file, see the samples/config directory in the archive (ZIP) file you downloaded for this connector.

  5. Run the container with minimal configuration as follows:

    In Docker, use the following command:

    docker run -d --name my-connector \
    -v `pwd`/libs/:/app/external/libs/:ro \
    -v `pwd`/config/:/app/external/spring/config/:ro \
    solace/solace-pubsub-connector-mqtt:<version>

    In Podman, use the following command:

    podman run -d --name my-connector \
    -v `pwd`/libs/:/app/external/libs/:ro \
    -v `pwd`/config/:/app/external/spring/config/:ro \
    solace/solace-pubsub-connector-mqtt:<version>

Where <version> is the version of the connector you are using, such as 3.2.0 .

Connecting to Services on the Host

If services (such as PubSub+ event broker) are exposed on the localhost, they can be referenced using the container platform’s special DNS name using SOLACE_JAVA_HOST, which resolves to the internal IP address that's used by the host.

For example in Docker, use the following command:

docker run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/config/:/app/external/spring/config/:ro \
--env SOLACE_JAVA_HOST=host.docker.internal:55555 \
solace/solace-pubsub-connector-mqtt:3.2.0

For example in Podman, use the following command:

podman run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/config/:/app/external/spring/config/:ro \
--env SOLACE_JAVA_HOST=host.containers.internal:55555 \
solace/solace-pubsub-connector-mqtt:3.2.0

Configuring a Health Check

You can configure the health to perform the following things:

  • Creates a regular read-only user called healthcheck with a password using SOLACE_CONNECTOR_SECURITY_USERS_0_NAME and SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD.
  • Uses the healthcheck user as the user to poll the management health endpoint in the container’s healthcheck command and fails it if the connector is unhealthy.

Here’s a basic example command of how to configure the healthcheck for the container:

For example in Docker, use the following command:

docker run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/application.yml:/app/external/spring/config/application.yml:ro \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_NAME=healthcheck \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD=healthcheck \
--healthcheck-command="curl -X GET -u healthcheck:healthcheck --fail
localhost:8090/actuator/health" \
solace/solace-pubsub-connector-mqtt:3.2.0

For example in Podman, use the following command::

podman run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/application.yml:/app/external/spring/config/application.yml:ro \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_NAME=healthcheck \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD=healthcheck \
--healthcheck-command="curl -X GET -u healthcheck:healthcheck --fail
localhost:8090/actuator/health" \
solace/solace-pubsub-connector-mqtt:3.2.0

Specifying Configuration Using Spring Configuration Properties

You can provide Spring configuration properties to this container using one of the following ways:

Port Configuration

The following ports are required for the container:

Port Usage
8090

The connector’s management endpoint.

Volume Configuration

These are the supported directories for which volumes and bind mounts can be created:

Contents Container Path Required or Optional Recommended Permission
Spring configuration files

/app/external/spring/config/

Required unless all properties are defined using environment variables Read-Only
Libraries /app/external/libs/ Required Read-Only
Classpath files /app/external/classpath/ Optional Read-Only
Output files /app/external/output/ Optional Read/Write

 

Volume: Spring Configuration Files

The Spring configuration files volume is used to add Spring configuration files (such as application.yml, etc.), add a read-only volume, or bind a mount to /app/external/spring/config/.

This directory follows the same semantics as Spring’s default config/ directory. This fact means that this connector automatically finds and loads Spring configuration files from the following locations when the connector starts:

  • The root of /app/external/spring/config/.
  • Immediate child directories of /app/external/spring/config/.

If you want configuration files for multiple, different connectors within the same config directory for use in different environments (e.g., development, production, etc.), we recommend that you use Spring Boot Profiles instead of child directories. For example:

  • Set up your configuration like this:

    • config/application-prod.yml
    • config/application-dev.yml

  • Do not do this:

    • config/prod/application.yml
    • config/dev/application.yml

Child directories are intended to be used for merging configuration from multiple sources of config properties. For more information and an example of when you might want to use multiple child directories to compose your application’s configuration, see the Spring Boot documentation.

Volume: Libraries

The Libraries volume adds additional libraries, adds a read-only volume, or binds a mount to /app/external/libs/.

This libs directory is provided as the location for the Java library dependencies (external JAR files) that are either required or required only when using certain features of the connector (such as Prometheus libraries when using the metrics export to Prometheus feature in your connector configuration). Solace does not provide the required JAR files due to licensing considerations. These JAR files are required as part of the deployment of the connector for it to operate correctly.

See the documentation provided in the libs directory of the connector in the ZIP file for more information.

Volume: Classpath Files

The Classpath Files volume adds a location for arbitrary files (not JAR libraries nor Spring Boot configuration files), adds a read-only volume, or binds a mount to /app/external/classpath/.

This directory must not contain JAR files for libraries or Spring Boot configuration files, otherwise there is a risk of libraries not getting picked up during the deployment of the connector and overwriting the connector’s internal configuration.

Volume: Output Files

The Output Files volume is for some features that support writing output files, such as logging to a file. To capture these, add a read/write volume or bind the mount to /app/external/output/.

When using features that generates files, you must configure the features so that the files are generated to the /app/external/output/ directory. Generating files to any other directory is not supported.

Configuring the JVM

You can set the JDK_JAVA_OPTIONS environment variable on the container to configure the Java Virtual Machine (JVM). See the JDK documentation for more information.

This container is provided as an example and has been tested using:

  • Two active processsors (specified using -XX:ActiveProcessorCount=2).
  • A maximum heap memory of 2 GB (specified using -Xmx2048m).