---
schema_version: "1"
id: c91cc7f8f5b213ff0e89d1ab95a3bf41f195b3b4d57261c160ac25738028ba92
title: Idempotent Message Validator (<idempotent-message-validator/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-idempotent-message-validator.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-idempotent-message-validator
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f151ceff7dbf566931ae2a8099958df15458406ee02b0269a2e1abb8866a8edf
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

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

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

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:

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

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Idempotent message validator</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr><tr><td><p><strong>Value expression</strong></p></td><td><p><code>valueExpression</code></p></td><td><div><div><p>N/A</p></div></div></td></tr><tr><td><p><strong>Id expression</strong></p></td><td><p><code>idExpression</code></p></td><td><div><div><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></div></div></td></tr><tr><td><p><strong>Store prefix</strong></p></td><td><p><code>storePrefix</code></p></td><td><div><div><p>N/A</p></div></div></td></tr><tr><td><p><strong>Object store</strong></p></td><td><p><code>objectStore</code></p></td><td><div><div><p>N/A</p></div></div></td></tr></tbody></table>

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

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

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

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

## See Also

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