2 Home
gitea_admin edited this page 2026-03-11 14:41:19 +00:00

MongoDB

Perform operations on MongoDB documents and collections.

Metadata

Property Value
Scheme mongodb
Support Level Stable
Labels database
Version 4.10.2

Maven Dependency

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mongodb</artifactId>
    <version>4.10.2</version>
</dependency>

Endpoint Properties

Name Type Required Default Description
connectionBean string Sets the connection bean reference used to lookup a client for connecting to a database if no hosts parameter is present.
collection string Sets the name of the MongoDB collection to bind to this endpoint
collectionIndex string Sets the collection index (JSON FORMAT : { field1 : order1, field2 : order2})
connectionUriString string Set the whole Connection String/Uri for mongodb endpoint.
createCollection boolean true Create the collection during initialisation if it doesn't exist. Default is true.
database string Sets the name of the MongoDB database to target
hosts string Host address of mongodb server in host:port format. It's possible to also use more than one address, as a comma separated list of hosts: host1:port1,host2:port2. If this parameter is specified, the provided connectionBean is ignored.
mongoConnection object Sets the connection bean used as a client for connecting to a database.
operation object Sets the operation this endpoint will execute against MongoDB.
outputType object Convert the output of the producer to the selected type: DocumentList Document or MongoIterable. DocumentList or MongoIterable applies to findAll and aggregate. Document applies to all other operations.
consumerType string Consumer type.
bridgeErrorHandler boolean false Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exceptionHandler object To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exchangePattern object Sets the exchange pattern when the consumer creates an exchange.
lazyStartProducer boolean false Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.
appName string Sets the logical name of the application. The application name may be used by the client to identify the application to the server, for use in server logs, slow query logs, and profile collection. Default: null
compressors string Specifies one or more compression algorithms that the driver will attempt to use to compress requests sent to the connected MongoDB instance. Possible values include: zlib, snappy, and zstd. Default: null
connectTimeoutMS integer 10000 Specifies the maximum amount of time, in milliseconds, the Java driver waits for a connection to open before timing out. A value of 0 instructs the driver to never time out while waiting for a connection to open. Default: 10000 (10 seconds)
cursorRegenerationDelay duration 1000 MongoDB tailable cursors will block until new data arrives. If no new data is inserted, after some time the cursor will be automatically freed and closed by the MongoDB server. The client is expected to regenerate the cursor if needed. This value specifies the time to wait before attempting to fetch a new cursor, and if the attempt fails, how long before the next attempt is made. Default value is 1000ms.
directConnection boolean false Specifies that the driver must connect to the host directly. Default: false
dynamicity boolean false Sets whether this endpoint will attempt to dynamically resolve the target database and collection from the incoming Exchange properties. Can be used to override at runtime the database and collection specified on the otherwise static endpoint URI. It is disabled by default to boost performance. Enabling it will take a minimal performance hit.
heartbeatFrequencyMS integer heartbeatFrequencyMS controls when the driver checks the state of the MongoDB deployment. Specify the interval (in milliseconds) between checks, counted from the end of the previous check until the beginning of the next one. Default: Single-threaded drivers: 60 seconds. Multithreaded drivers: 10 seconds.
loadBalanced boolean false If true the driver will assume that it's connecting to MongoDB through a load balancer.
localThresholdMS integer 15 The size (in milliseconds) of the latency window for selecting among multiple suitable MongoDB instances. Default: 15 milliseconds.
maxConnecting integer 2 Specifies the maximum number of connections a pool may be establishing concurrently. Default: 2
maxIdleTimeMS integer 0 Specifies the maximum amount of time, in milliseconds, the Java driver will allow a pooled connection to idle before closing the connection. A value of 0 indicates that there is no upper bound on how long the driver can allow a pooled collection to be idle. Default: 0
maxLifeTimeMS integer 0 Specifies the maximum amount of time, in milliseconds, the Java driver will continue to use a pooled connection before closing the connection. A value of 0 indicates that there is no upper bound on how long the driver can keep a pooled connection open. Default: 0
maxPoolSize integer 100 The maximum number of connections in the connection pool. The default value is 100.
maxStalenessSeconds integer -1 Specifies, in seconds, how stale a secondary can be before the driver stops communicating with that secondary. The minimum value is either 90 seconds or the heartbeat frequency plus 10 seconds, whichever is greater. For more information, see the server documentation for the maxStalenessSeconds option. Not providing a parameter or explicitly specifying -1 indicates that there should be no staleness check for secondaries. Default: -1
minPoolSize integer 0 Specifies the minimum number of connections that must exist at any moment in a single connection pool. Default: 0
readPreference string PRIMARY Configure how MongoDB clients route read operations to the members of a replica set. Possible values are PRIMARY, PRIMARY_PREFERRED, SECONDARY, SECONDARY_PREFERRED or NEAREST
readPreferenceTags string A representation of a tag set as a comma-separated list of colon-separated key-value pairs, e.g. dc:ny,rack:1. Spaces are stripped from the beginning and end of all keys and values. To specify a list of tag sets, using multiple readPreferenceTags, e.g., readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags= Note the empty value for the last one, which means match any secondary as a last resort. Order matters when using multiple readPreferenceTags.
replicaSet string Specifies that the connection string provided includes multiple hosts. When specified, the driver attempts to find all members of that set.
retryReads boolean true Specifies that the driver must retry supported read operations if they fail due to a network error. Default: true
retryWrites boolean true Specifies that the driver must retry supported write operations if they fail due to a network error. Default: true
serverSelectionTimeoutMS integer 30000 Specifies how long (in milliseconds) to block for server selection before throwing an exception. Default: 30,000 milliseconds.
socketTimeoutMS integer 0 Specifies the maximum amount of time, in milliseconds, the Java driver will wait to send or receive a request before timing out. A value of 0 instructs the driver to never time out while waiting to send or receive a request. Default: 0
srvMaxHosts integer The maximum number of hosts from the SRV record to connect to.
srvServiceName string mongodb Specifies the service name of the SRV resource recordsthe driver retrieves to construct your seed list. You must use the DNS Seed List Connection Format in your connection URI to use this option. Default: mongodb
tls boolean false Specifies that all communication with MongoDB instances should use TLS. Supersedes the ssl option. Default: false
tlsAllowInvalidHostnames boolean false Specifies that the driver should allow invalid hostnames in the certificate for TLS connections. Supersedes sslInvalidHostNameAllowed. Has the same effect as tlsInsecure by setting tlsAllowInvalidHostnames to true. Default: false
waitQueueTimeoutMS integer 120000 Specifies the maximum amount of time, in milliseconds that a thread may wait for a connection to become available. Default: 120000 (120 seconds)
writeConcern string ACKNOWLEDGED Configure the connection bean with the level of acknowledgment requested from MongoDB for write operations to a standalone mongod, replicaset or cluster. Possible values are ACKNOWLEDGED, W1, W2, W3, UNACKNOWLEDGED, JOURNALED or MAJORITY.
writeResultAsHeader boolean false In write operations, it determines whether instead of returning WriteResult as the body of the OUT message, we transfer the IN message to the OUT and attach the WriteResult as a header.
zlibCompressionLevel integer Specifies the degree of compression that Zlib should use to decrease the size of requests to the connected MongoDB instance. The level can range from -1 to 9, with lower values compressing faster (but resulting in larger requests) and larger values compressing slower (but resulting in smaller requests). Default: null
fullDocument object default Specifies whether changeStream consumer include a copy of the full document when modified by update operations. Possible values are default, updateLookup, required and whenAvailable.
streamFilter string Filter condition for change streams consumer.
authSource string The database name associated with the user's credentials.
password string User password for mongodb connection
username string Username for mongodb connection
persistentId string One tail tracking collection can host many trackers for several tailable consumers. To keep them separate, each tracker should have its own unique persistentId.
persistentTailTracking boolean false Enable persistent tail tracking, which is a mechanism to keep track of the last consumed message across system restarts. The next time the system is up, the endpoint will recover the cursor from the point where it last stopped slurping records.
tailTrackCollection string Collection where tail tracking information will be persisted. If not specified, MongoDbTailTrackingConfig#DEFAULT_COLLECTION will be used by default.
tailTrackDb string Indicates what database the tail tracking mechanism will persist to. If not specified, the current database will be picked by default. Dynamicity will not be taken into account even if enabled, i.e., the tail tracking database will not vary past endpoint initialization.
tailTrackField string Field where the last tracked value will be placed. If not specified, MongoDbTailTrackingConfig#DEFAULT_FIELD will be used by default.
tailTrackIncreasingField string Correlation field in the incoming record which is of increasing nature and will be used to position the tailing cursor every time it is generated. The cursor will be (re)created with a query of type: tailTrackIncreasingField greater than lastValue (possibly recovered from persistent tail tracking). Can be of type Integer, Date, String, etc. NOTE: No support for dot notation at the current time, so the field should be at the top level of the document.