Loading

How to Set Custom Correlation Id for Flows with HTTP Endpoint in Mule 4

Data pubblicazione: Aug 5, 2025
Operazione

GOAL

You want to trace the messages flowing through your Mule 4 application using a single unique Id. In many cases, you intend to trace the messages across Multiple applications which can be traced in application logs using an unique Id. How to achieve this?

Fasi

By design, Correlation Ids cannot be changed within a flow in Mule 4 applications and can be set only at source. This ID is part of the Event Context and is generated as soon as the message is received by the application. When a HTTP Request is received, the request is inspected for "X-Correlation-Id" header.

  • If "X-Correlation-Id" header is present, HTTP connector uses this as the Correlation Id.
  • If "X-Correlation-Id" header is NOT present, a Correlation Id is randomly generated.

For Incoming HTTP Requests:
In order to set a custom Correlation Id, the client invoking the HTTP request must set "X-Correlation-Id" header. This will ensure that the Mule Flow uses this Correlation Id.

For Outgoing HTTP Requests:
You can also propagate the existing Correlation Id to downstream APIs. By default, all outgoing HTTP Requests send "X-Correlation-Id" header. However, you can choose to set a different value to "X-Correlation-Id" header or set "Send Correlation Id" to NEVER.
Refer documentation.

Numero articolo Knowledge

001116575

 
Caricamento
Salesforce Help | Article