[ETL]: Atomic Integer

This recipe is an example of how to design a simple ETL Chainset for the step, “Atomic Integer” using the ETL Designer module on Ambience 2021.

Background information on Atomic Integer:

  • This step reads and increments an integer value in MongoDB in a thread-safe way so that multiple concurrent calls will each receive a different incrementing value.
  • More information can be found in the ETL Dictionary.

Prerequisites:

  • A database:collection which will hold the counters.

Notes:

  • A collection can have many counters but each counter needs to be identified by a unique _id string identifier

ETL Atomic Integer:

This example uses a database:collection that consists of the following data:

{"_id": "InvoiceNo", "Type": "InvoiceNo", "Value": 45 }
{"_id": "QuotationNo", "Type":"QuotationNo","Value": 100}
  1. After importing the data, head over to the ETL module.
    More information on how to Import data can be found here: Imports

  2. Create a new ETL Step.
    For example,

  3. Add a new Blank Chain.
    For example,

  4. Add the step, “MongoDB Atomic Integer” in the new chain & fill in the fields:
    For example,

    *expand the icon on the top right corner for more details on this step.

  5. For visualization purposes, do add in the following 2 steps, “MongoDB Definition” & “MongoDB Reader”
    For example,

  6. Run Steps.


Output:
// Initial Data

// After running the steps


[Value for InvoiceNo is incremented by 1]

// To increment “QuotationNo”, do add in & configure another “MongoDB Atomic Integer” step.