MongoDB Connector for Camunda 8- Part I

Integrating Camunda, a popular open-source workflow automation and business process management platform, with MongoDB, a NoSQL database, can offer powerful capabilities for managing and executing business processes while efficiently storing and retrieving data. This integration can enhance the flexibility and scalability of your workflow applications.

The MongoDB Connector provides features to integrate Camunda Workflows with MongoDB.

  • Written by

  • Hariharan
    Camunda Expert at Acheron
  • August 29, 2023
  • 9 mins read

What is MongoDB ?

MongoDB is a leading NoSQL database system designed for managing large volumes of unstructured or semi-structured data. It employs a document-oriented approach, storing data in flexible JSON-like documents within collections. Its schema flexibility allows easy handling of dynamic data, while powerful querying and aggregation capabilities facilitate data retrieval and analysis. Its popularity stems from its ease of use, community support, and applicability in a wide range of applications.

For more details about MongoDB, visit .

What is Camunda 8 ?

Camunda Platform 8 is a powerful tool that helps manage complex business processes involving people, systems, and devices. It allows business users to work together with developers to design and automate entire processes using flowcharts powered by BPMN (Business Process Model and Notation).

It also includes DMN (Decision Model and Notation) decision tables that help make decisions quickly, efficiently, and based on logical rules. This combination of features supports efficient workflows and decision-making at scale.

For more info about Camunda 8, visit What is Camunda Platform 8? | Camunda Platform 8 Docs.

MongoDB Custom Outbound Camunda Connector :

We are living through the digital era where we are exposed to and a part of so much digital information that is stored and manipulated in the form of databases. From registering your details in a government registry to ordering your food online, databases play a vital role. Any activity we want to do comprises a series of steps with a definite start and end and the steps need to be executed in a specific sequence to achieve the desired result / output. Even the example of ordering food online involves a set of steps like given in the below process diagram,

In a scenario like this, it is essential to integrate a database into the process to improve user experience, like recommending similar products to the user that they had previously rated good, giving loyalty programs, etc..,

Here we are using the universal process orchestrator, Camunda to model a process, and inorder to perform the database operations, I have developed a custom Camunda connector that interacts with MongoDB and performs our required actions. Let’s walk through each operation one by one, by considering the scenario of ticket booking management system for bus travel.

Pre - requisite :

Kindly go through the information provided in the following link for this connector to function.

Create a Collection :

Now that we have just started a travel agency, we need a collection to store all the bookings that are coming in. For that, we will first create a collection. Let's model the process.

  • To the start event, I am appending an activity and naming it as “Create Collection”. Now, let’s click on the wrench icon to configure this activity. Now, since I have added the JSON file to the directory “[%MODELER_INSTALLATION_DIRECTORY%]/resources/element-templates”, we will be able to see the connector template under “Connectors” category.
 
  • Click and select the MongoDB Connector. This will render the connector template to fill in the details.
 
  • Under the Operation menu, click and select “Create Collection”.
 
  • And then, fill the Input and Output Mapping details, like the database name we want, and the collection name we want.
 
  • Now, let’s add an end task.
  • Deploy the process to the Zeebe cluster.
  • Start an instance of the process.
  • When we go and check the instance in operate, we are able to see the response as,
  • Inorder to verify the same, let’s go and check in the MongoDB. I have installed MongoDB Compass, and am checking for the databases present. We are able to find as below,
  • Thus, our Create Operation is executed from a Camunda process to the MongoDB database.

Insert Documents :

Now that we have created our collection to store data, let’s consider the scenario of a user booking a ticket, and inserting those booking to the database.

  • Here, I have created a simple process for facilitating the Insert operation.
  • Then, I have created this form that the customer need to fill to book the ticket, and binded it to the user task by adding the JSON. Once they submit the form, the details are entered into the collection.
  • Let's configure the connector template as follows,
  • Here, we are populating the process variables to the respective field names in the JSON to attain dynamic insertion. Now, let's deploy and start an instance of the process.
  • In the tasklist, let us fill the details as a customer.
  • And in the operate, our response is as follows,
  • Inorder to verify the same, let’s go and check in the MongoDB. We are able to find the data inserted as below,

  • Thus, our Insert Operation is also executed from Camunda process and persisted in the MongoDB database. In the hindsight, I am adding a few more documents into the database to support describing other operations.

In this first part of our MongoDB blog series, we have covered the essential steps to get us started with our MongoDB journey. We learned how to create collections to organize your data and explored various ways to insert documents into these collections. By now, you should be familiar with the foundation of setting up your MongoDB environment and populating it with initial data.

In the next part of this series, we will delve deeper into retrieving data from MongoDB. Building on the knowledge gained here, we'll be equipped to harness the power of MongoDB's querying capabilities to retrieve specific information from a collection. Let's dive into the world of retrieving data in MongoDB!

Contact :

More to explore