Skip to content

mongodb://

MongoDB via mongo-driver/v2. 17 producer operations (CRUD, aggregate, bulkWrite, admin) plus two consumer modes (change streams on replica sets, tailable cursors on capped collections). Full TLS shape, SCRAM and X.509 auth.

URI shape

mongodb://<collection>/<operation>?database=<db>&uri=mongodb://<host>:27017&...

A query-string URI shape (empty path, ?collection=&operation=...) is also accepted. database= is required either way.

Operations

Type Operations
Read findAll, findOneByQuery, findById, findDistinct, count, aggregate
Write insert, save, update, remove, bulkWrite
Atomic findOneAndUpdate, findOneAndReplace, findOneAndDelete
Admin command, getDbStats, getColStats
Consumer watch (change streams), tailable (capped collections)

Parameters

Lifted directly from Component.Describe() — only the parameters that are actually implemented appear (no-silent-noop rule).

Path / operation

Param Type Default Producer/Consumer/Both Description
collection string required Both Collection name. Alternate to URI path 1st segment.
operation enum required Both One of the operations listed above. Required if URI path 2nd segment is empty.
database string required Both Database name. Required.

Connection

Param Type Default Producer/Consumer/Both Description
uri string mongodb://localhost:27017 Both MongoDB connection URI. Also accepted as connectionUriString.
connectionUriString string — Both Alias for uri.
hosts string — Both Comma-separated host[:port] list. Synthesises a connection URI when uri is unset.
createCollection boolean false Both Auto-create the target collection on first use.
collectionIndex string — Both JSON-encoded index spec applied when createCollection=true.
outputType enum DocumentList Producer Result shape for read ops: DocumentList, Document, MongoIterable.
dynamicity boolean false Producer Read DB/collection from per-message headers (mongodb.DATABASE, mongodb.COLLECTION) instead of cfg.
writeResultAsHeader boolean false Producer Set write results on mongodb.WRITE_RESULT header instead of replacing the body.
connectionName / appName string — Both Display name for mongo-management dashboards.

Authentication

Param Type Default Description
username / password string — SCRAM credentials.
authSource string admin SCRAM auth database.

TLS

tls / secure, tlsCAFile, tlsCertFile, tlsKeyFile, tlsInsecureSkipVerify, tlsAllowInvalidHostnames, tlsMinVersion / tlsMaxVersion (TLSv1.0..TLSv1.3), tlsCipherSuites. Full options described in the source.

Tuning

connectTimeoutMS, socketTimeoutMS, serverSelectionTimeoutMS, heartbeatFrequencyMS, localThresholdMS, maxIdleTimeMS, maxPoolSize (default 100), minPoolSize, replicaSet, directConnection, retryReads (default true), retryWrites (default true), readPreference (PRIMARY/PRIMARY_PREFERRED/SECONDARY/SECONDARY_PREFERRED/NEAREST), writeConcern (ACKNOWLEDGED/W1/W2/W3/UNACKNOWLEDGED/JOURNALED/MAJORITY), compressors, zlibCompressionLevel.

Consumer-only

Param Default Description
consumerType changeStreams changeStreams (modern, needs replica set / sharded cluster) or tailable (capped collections).
streamFilter — JSON $match pipeline-stage applied server-side (change streams).
fullDocument default default/updateLookup/required/whenAvailable.
persistentId auto Identifier under which the tail position is persisted. Defaults to <database>.<collection> when persistentTailTracking=true.
persistentTailTracking false Persist resume token / cursor position across restarts.
tailTrackCollection _helix_mongo_tail_tracking Storage collection for tail-tracking docs.
tailTrackDb = database Storage DB for tail-tracking docs.
tailTrackIncreasingField — Name of monotonically-increasing field on source docs (tailable only).
cursorRegenerationDelay 1s Delay before re-opening a closed tailable cursor.

Helix-native reconnect

reconnect (default true), maxReconnectAttempts (default -1, unlimited), reconnectTimeWait (default 2s).

Header filtering

headerIncludePattern, headerExcludePattern — regex applied to exchange headers as they pass.

Examples

Find all documents in a collection:

- id: list-users
  from: direct://list-users
  steps:
    - to: mongodb://users/findAll?database=app&uri=mongodb://localhost:27017

Insert from a JSON body:

- to: mongodb://orders/insert?database=shop

Change-stream consumer with persistence across restarts:

- id: orders-feed
  from: mongodb://orders/watch?database=shop&persistentTailTracking=true
  steps:
    - to: kafka://orders-events

Tailable cursor on a capped collection:

- from: mongodb://events/tailable?database=metrics&tailTrackIncreasingField=ts&persistentTailTracking=true
  steps: [...]

Headers

The component sets / honours several per-exchange headers:

Header Direction Description
mongodb.DATABASE in (producer) When dynamicity=true, overrides target DB.
mongodb.COLLECTION in (producer) When dynamicity=true, overrides target collection.
mongodb.WRITE_RESULT out (producer) Write-op result, when writeResultAsHeader=true.
mongodb.OPERATION out The operation that was executed.

Refer to pkg/component/mongodb/headers.go for the exhaustive list.

Source

  • pkg/component/mongodb/mongodb.go — entry point + Describe().
  • pkg/component/mongodb/operations.go — operation enum + dispatch.
  • pkg/component/mongodb/producer.go — producer implementation.
  • pkg/component/mongodb/consumer_changes.go — change-stream consumer.
  • pkg/component/mongodb/consumer_tailable.go — tailable consumer.
  • pkg/component/mongodb/config.go — URI parsing.

See also