Contact Us 1-800-596-4880

Idempotent Message Validator (<idempotent-message-validator/>)

Ensure that only unique messages continue through a flow execution by checking the unique ID of the incoming message.

You can use any incoming attribute of the Mule message as an ID, or you can compute the ID by configuring a DataWeave expression. You can also use the DataWeave Crypto functions to compute hashes (SHA, MD5) from the data.

Component XML

This component supports the following XML structure:

<idempotent-message-validator
  doc:name="Idempotent message validator"
  doc:id="cyuupj"
  idExpression="#[]">
  <!-- Object Store to use for storing the processed message IDs -->
  <os:private-object-store />

</idempotent-message-validator>

Idempotent Message Validator (<idempotent-message-validator/>) attributes are configurable through the UI and XML.

Attribute Name Attribute XML Description

Idempotent message validator (default)

doc:name

Editable name for the component to display in the canvas.

N/A

doc:id

Automatically generated identifier for the component.

Value expression

valueExpression

N/A

Id expression

idExpression

The expression Mule uses to generate the ID. You can use a DataWeave function to calculate the ID, or you can extract the ID from any existing value of the Mule message.

Store prefix

storePrefix

N/A

Object store

objectStore

N/A

Examples

The examples show how to configure an Idempotent Message Validator to extract an ID from an HTTP request for use as a unique identifier and how to hash the payload using a DataWeave expression and use the message ID as the unique identifier.

Example: Generate an ID from an HTTP Request

The following example shows an Idempotent Message Validator configured to extract the query parameter ID from the HTTP request and use that value as a unique identifier to filter the message:

<flow name="myFlow">
  <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/"/>
  ...
  <idempotent-message-validator doc:name="Idempotent Message Validator" idExpression="#[attributes.queryParams.id]"/>
  ...
</flow>

Example: Generate an ID by Hashing the Payload With DataWeave

The following example shows an Idempotent Message Validator configured to hash the payload using a DataWeave expression, store the result in a persistent object store, and then use the processed message IDs as unique identifiers for filtering the message:

<flow name="myFlow">
  <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/"/>
  ...
  <idempotent-message-validator doc:name="Idempotent Message Validator" idExpression="
    #[%dw 2.0
      import dw::Crypto
      output application/octet-stream
      ---
      Crypto::hashWith(payload,'MD5')]">
    <os:private-object-store alias="privateObjectStore"
       entryTtl="1"
       entryTtlUnit="MINUTES"
       maxEntries="10" />
  </idempotent-message-validator>
  ...
</flow>