---
schema_version: "1"
id: e043cc64a601531a3b53b305356539ddf59e5e94dddd65ac9b4658d8c6850cd2
title: Idempotent Message Validator
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/idempotent-message-validator.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/idempotent-message-validator
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 73026854b84ad4e563497f76e797c71e6b982b8c3c2d654cbb9a241ddb3539c3
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
keywords: anypoint studio, filters, conditional, gates, idempotent
---

# Idempotent Message Validator

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The Idempotent Message Validator ensures that only unique messages continue through a flow’s
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.

## Message Hashing

DataWeave enables you to import the `Crypto` library to execute hashing functions. Calculating a
hash can be useful when you want to compute a unique ID for the Mule message. For example, if you
want to get an MD5 hash from the payload and use it as the ID, open the Idempotent Message Validator
properties in Anypoint Studio and set **ID Expression** (`idExpression` in XML) to the following
DataWeave expression:

#\[ %dw 2.0 output text/plain import dw::Crypto --- Crypto::hashWith(payload,'MD5') \]

## Examples

- 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:

  ```xml
  <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>
  ```

- The next 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 the unique identifier to filter the message:

  ```xml
  <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>
  ```

## Parameter Reference

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>ID Expression</p></td><td><p>Expression</p></td><td><p>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.</p></td><td><p><code>#[correlationId]</code></p></td><td><p>No</p></td></tr><tr><td><p>Value Expression</p></td><td><p>Expression</p></td><td><p>This parameter is not used. Setting a value has no effect.</p></td><td><p><code>#[correlationId]</code></p></td><td><p>No</p></td></tr><tr><td><p>Object Store</p></td><td><p>Object Store</p></td><td><p>Either a name to reference a global object store or a definition of a private object store where the component stores the processed message IDs.</p></td><td><p>Object Store created by the Object Store Manager. Not persistent, with an entry TTL of 5 MINUTES and an expiration interval of 6 SECONDS.</p></td><td><p>No</p></td></tr><tr><td><p>Store Prefix</p></td><td><p>String</p></td><td><p>Defines the prefix of the object store names. This value is used only for the internally built object store.</p></td><td><p><em>configFileName</em>.<em>flowName</em>.IdempotentMessageValidator</p></td><td><p>No</p></td></tr></tbody></table>

### Throws

- `MULE:DUPLICATE_MESSAGE`

## See Also

- [Crypto (dw::Crypto)](https://docs.mulesoft.com/dataweave/latest/dw-crypto)
