Configuring messages to be sent

All Producer message actions require a body to be defined that is published to the Collection in the MongoDB instance. You must select transport and formatter to publish the messages.

Procedure

  1. Configure the Producer message actions in the Publish window.
    image of the producer settings section in the publish dialog box.
  2. Select the Operation from the list. the Operation indicates how the messages interact with the database.
    Select from the following operations:
    Operation Description

    insert

    This operation inserts the JSON message contained in the body into the Collection.

    save

    This operation updates an entire record based on the document ID specified in the body of the JSON message. If a document with that ID does not exist in the Collection, the document is inserted instead.

    update

    This operation updates all, or part of a document based on a Filter specified in JSON that describes which documents to update. The body represents what is to be updated in JSON form.

    This example of an updated body sets the lastName and age fields in the documents that matches the specified Filter:

    {"$set":{"lastName": "Doe", "age": 41}}
    Operation Description

    CamelMongoDbMultiUpdate

    This operation explains that the update should be applied to all matching documents. Otherwise only the first document matching the Filter is updated. The default value is unselected.

    CamelMongoDbUpsert

    This operation explains that the database should create the element if it does not exist. The default value is unselected.

    Filter

    This operation refers to the documents to update in the Collection. The Filter is defined in JSON form. Example: { "brand": "ABC" } which only updates documents that have a brand field with the value ABC.

    remove

    This operation removes one or more documents that matches the criteria specified in the body of the JSON message.

    This example removes all documents with an age field with a value of 25:

    {"age": "25"}
  3. Specify a name for the Collection to be accessed or written. If you want to automatically create that collection if it does not exist, select the createCollection check box.