Subscribing to MongoDB messages

All Consumer message actions require a body to be defined that is to subscribe to messages in the Collection in the MongoDB instance. You must select the transporter and formatter to subscribe to messages.

Procedure

  1. Configure the Consumer message actions in the Subscribe window.
    image of the screen to set subscriber settings
  2. Select the Operation from the list. The Operation indicates how the messages interact with the database.
    Select from the following operations:
    Operation Description

    findById operation

    Fetches a single document from the database based on its document Id.
    Operation Description

    Id

    Explains that the Id of the document to be fetched from the database.

    findOneByQuery

    Fetches a single document from the database based on query criteria.

    Operation Description

    Query

    Explains that a query in JSON form is used to fetch the desired document.

    findAll

    Fetches all of the documents from a table. The documents fetched are limited by operation.

    Operation Description

    CamelMongoDbNumToSkip

    Discards a given number of documents at the beginning of the returned results before returning them.

    CamelMongoDbLimit

    Limits the number of documents returned.

    count

    Returns the number of documents in the specified collection. The returned value is a Long value represented as a String.

    getDbStats

    Fetches the statistics about the specified database defined in the transport. Collection is not required.

    getColStats

    Fetches the statistics about the specified Collection from the database defined in the transport.

    command

    Runs a command on the MongoDB instance specified in the transport.

    Operation Description
    Command Body

    Explains the command to run.

    The following example:

    {"hostInfo": 1}

    returns statistics about the host running the MongoDB instance.

  3. Specify a name for the Collection to be accessed. If you want to automatically create the collection if it does not exist, select the createCollection check box.