Configuring Connection Details

This section provides instructions for configuring the connection details required to establish communication between the Micro-Integration and your third-party system.

For information about configuring the connection to the event broker, see Connecting to Your Event Broker .

For information about configuring error handling, see Error Handling.

This Micro-Integration supports workflows in the following direction:

  • Solace to MongoDB

The name of the binder for MongoDB is mongodb.

To share settings across all workflows in a Micro-Integration, configure the binder-specific parameters under default at the binder level instead of under a workflow-specific identifier (for example, input-0) in bindings. This reduces repetition when multiple workflows use the same parameter values. Workflow-specific settings override default settings when both are present.

Note that default is a sibling of bindings; it is not nested under bindings. Use the same hierarchy under default as you use under bindings.<binding-name>. For example, for bindings.input-0.consumer.someProperty=someValue the default setting is default.consumer.someProperty=someValue.

spring:
  cloud:
    stream:
      <binder-name>:
        default:
          <shared parameters>
        bindings:
          input-0:
            <workflow-specific parameters>

Prerequisites

  • The target MongoDB database and collection must already exist. This Micro-Integration does not automatically create databases or collections.

  • The database user specified in the connection configuration must have the necessary privileges to perform write operations on the target collection.

  • Message payloads must be JSON objects (or a single-element JSON array). The Micro-Integration converts the payload to a MongoDB document before writing.

  • If you want the Micro-Integration to update existing documents in UPSERT mode (the default), ensure each message payload includes an _id field that matches the target document. If the payload does not include an _id field, MongoDB generates a new unique _id and always inserts a new document. In INSERT mode, the Micro-Integration always inserts a new document regardless of whether the payload contains an _id field; if it does not, MongoDB generates one automatically.

MongoDB Connection Details

The following table lists the configuration options for connecting to MongoDB. These properties must be prefixed with mongodb in your application.yml file. The MongoDB Micro-Integration supports two authentication options:

# Option 1: Username/password authentication
mongodb:
  connection-string: mongodb://<host>:<port>
  database-name: <database-name>        # Optional
  username: <username>
  password: <password>
  auth-database: <auth-database>        # Optional; defaults to admin

# Option 2: TLS/mTLS authentication
mongodb:
  connection-string: mongodb://<host>:<port>
  database-name: <database-name>        # Optional
  tls-enabled: true
  trust-store-path: /path/to/truststore.p12
  trust-store-password: <trust-store-password>
  # key-store-path: /path/to/client.p12        # Optional; required for mTLS
  # key-store-password: <key-store-password>   # Optional; required for mTLS
Config Option Type Valid Values Default Value Description

mongodb.connection-string

String

Required. The MongoDB connection URI (for example, mongodb://host:27017).

mongodb.database-name

String

Optional. The default MongoDB database name. Can be overridden per-workflow via the destination setting (database.collection format).

mongodb.username

String

Optional. The username for SCRAM authentication with the MongoDB database. Required for username/password authentication.

mongodb.password

String

Optional. The password for SCRAM authentication with the MongoDB database. Required for username/password authentication.

mongodb.auth-database

String

admin

Optional. The MongoDB database where the user is defined.

mongodb.tls-enabled

boolean

true, false

false

Optional. When true, enables TLS for the MongoDB connection. Requires mongodb.trust-store-path and mongodb.trust-store-password.

mongodb.trust-store-path

String

Optional. Required when TLS is enabled. The path to the PKCS12 trust store containing the CA certificate used to validate the MongoDB server.

mongodb.trust-store-password

String

Optional. Required when TLS is enabled. The password for the PKCS12 trust store.

mongodb.key-store-path

String

Optional. The path to the PKCS12 key store containing the client certificate and private key for mutual TLS.

mongodb.key-store-password

String

Optional. The password for the PKCS12 key store.

MongoDB Binder Configuration Options

The following configuration options are available for MongoDB producers. Prefix the destination property with spring.cloud.stream.bindings.output-<workflow-id>. Prefix the operation property with spring.cloud.stream.mongodb.bindings.output-<workflow-id>.producer.endpoint.query-parameters.

Config Option Type Valid Values Default Value Description

destination

String

Required. The target MongoDB collection in database.collection format. Overrides mongodb.database-name for this workflow.

operation

String

UPSERT, INSERT

UPSERT

Optional. Specifies the write behavior for the collection. UPSERT inserts a new document or updates an existing document with the same _id. INSERT always inserts a new document.

Supported Payload Types

The MongoDB Micro-Integration accepts the following payload types. All payload types are internally converted to a document before being written to MongoDB.

Payload Type Description

Map

A Map<String, Object> payload. All map keys must be of type String.

List

A List containing exactly one element. Empty lists or lists with more than one element are not supported and cause the message to be rejected.

JSON String

A JSON object or single-element JSON array encoded as a String. Maximum size: 2 MB.

JSON Bytes

A JSON object or single-element JSON array encoded as a UTF-8 byte[]. Maximum size: 2 MB.

If a field in the payload is null or absent, that field is not included in the UPSERT operation.