blob: 108d16e7f7c76da36a6a8883ec493779211efa3c [file] [log] [blame]
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/mongodb-source.svg[] MongoDB Source
*Provided by: "Apache Software Foundation"*
*Support Level for this Kamelet is: "Preview"*
Consume documents from MongoDB.
If the persistentTailTracking option will be enabled, the consumer will keep track of the last consumed message and on the next restart, the consumption will restart from that message. In case of persistentTailTracking enabled, the tailTrackIncreasingField must be provided (by default it is optional).
If the persistentTailTracking option won't be enabled, the consumer will consume the whole collection and wait in idle for new documents to consume.
== Configuration Options
The following table summarizes the configuration options available for the `mongodb-source` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *collection {empty}* *| MongoDB Collection| Sets the name of the MongoDB collection to bind to this endpoint.| string| |
| *database {empty}* *| MongoDB Database| Sets the name of the MongoDB database to target.| string| |
| *hosts {empty}* *| MongoDB Hosts| Comma separated list of MongoDB Host Addresses in host:port format.| string| |
| password| MongoDB Password| User password for accessing MongoDB.| string| |
| persistentTailTracking| MongoDB Persistent Tail Tracking| 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.| boolean| `false`|
| tailTrackIncreasingField| MongoDB Tail Track Increasing Field| 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.| string| |
| username| MongoDB Username| Username for accessing MongoDB.| string| |
|===
NOTE: Fields marked with ({empty}*) are mandatory.
== Usage
This section summarizes how the `mongodb-source` can be used in various contexts.
=== Knative Source
The `mongodb-source` Kamelet can be used as Knative source by binding it to a Knative object.
.mongodb-source-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: mongodb-source-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: mongodb-source
properties:
collection: "The MongoDB Collection"
database: "The MongoDB Database"
hosts: "The MongoDB Hosts"
sink:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel
----
Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.
Save the `mongodb-source-binding.yaml` file into your hard drive, then configure it according to your needs.
You can run the source using the following command:
[source,shell]
----
kubectl apply -f mongodb-source-binding.yaml
----
==== *Dependencies*
The Kamelet needs the following dependencies:
- camel:kamelet
- camel:mongodb
- camel:jackson
==== *Binding to Knative using the Kamel CLI:*
The procedure described above can be simplified into a single execution of the `kamel bind` command:
[source,shell]
----
kamel bind mongodb-source -p "source.collection=The MongoDB Collection" -p "source.database=The MongoDB Database" -p "source.hosts=The MongoDB Hosts" channel:mychannel
----
This will create the KameletBinding under the hood and apply it to the current namespace in the cluster.
=== Kafka Source
The `mongodb-source` Kamelet can be used as Kafka source by binding it to a Kafka topic.
.mongodb-source-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: mongodb-source-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: mongodb-source
properties:
collection: "The MongoDB Collection"
database: "The MongoDB Database"
hosts: "The MongoDB Hosts"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
----
Ensure that you've installed https://strimzi.io/[Strimzi] and created a topic named `my-topic` in the current namespace.
Make also sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.
Save the `mongodb-source-binding.yaml` file into your hard drive, then configure it according to your needs.
You can run the source using the following command:
[source,shell]
----
kubectl apply -f mongodb-source-binding.yaml
----
==== *Binding to Kafka using the Kamel CLI:*
The procedure described above can be simplified into a single execution of the `kamel bind` command:
[source,shell]
----
kamel bind mongodb-source -p "source.collection=The MongoDB Collection" -p "source.database=The MongoDB Database" -p "source.hosts=The MongoDB Hosts" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
----
This will create the KameletBinding under the hood and apply it to the current namespace in the cluster.
==== Kamelet source file
Have a look at the following link:
https://github.com/apache/camel-kamelets/blob/main/mongodb-source.kamelet.yaml
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT