Loading

Understanding and Resolving Anypoint MQ Error "LockId provided is expired"

Publiseringsdato: Nov 4, 2025
Løsning

SYMPTOM

You are processing messages from an Anypoint MQ queue, but your Mule application fails with an ACK or NACK requests. This issue can be observed when the MQ flow is configurd with maxConcurrency (i.e maxConcurrency=1) limiting the cucurrent events from the flow level.

This situation commonly arises in the following scenarios:

  • FIFO queues configured with maxConcurrency=1, and the extended processing time for messages (NOTE. With FIFO, if message ordering is crucial, maxConcurrency=1 is required)
  • Standard queues (with or without maxConcurrency enabled) where individual message processing takes longer than the default lock duration.

The error log contains a 400 Bad Request message with the following details:

com.mulesoft.mq.restclient.exception.RestException: An error occurred while executing the operation: ACK ONE MESSAGE. Cause: 400 - Bad Request ({
  "status" : "failure",
  "statusMessage" : "LockId: AQEBpeUWnHhPYVU....Im8Q20oe0J provided is expired"
}).

CAUSE

This error occurs when the lockID TTL is expired. The default Acknowledgement timeout for an Anyoint MQ subscriber is 2 mintues if not explicitly configured. 

Detailed Message Flow Analysis (FIFO with maxConcurrency and long processing duration)

110 messages received by subscriber

DEBUG 2025-11-04 10:49:34,597

Received messages count: 10

2First message received and lockID received

DEBUG 2025-11-04 10:49:34,597

Message received with ID: 3f3bab4a-6642-487b-8b9f-4e36b6fcea8a and lock ID: AQEBLAG7BA0AH9y5yIQZTJyMLWL0HyarBc829WiH3ZYBucZmNs+......

3First message dispatched for processing

DEBUG 2025-11-04 10:49:34,644 

Message dispatched with ID: 3f3bab4a-6642-487b-8b9f-4e36b6fcea8a

4Second message received but queued (not yet dispatched)

DEBUG 2025-11-04 10:49:34,645

Message received with ID: 767ed392-b4f7-47d9-9a75-d0704ccf7ead and lock ID: AQEBpeUWnHhPYVUoFV5gBNMkwluz0Jl....

5First message processed and ACKed successfully

DEBUG 2025-11-04 10:51:05,109

Received response from DELETE https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1/organizations/<orgID>/environments/<envID>/destinations/testing-fifo/messages/3f3bab4a-6642-487b-8b9f-4e36b6fcea8a. Request Id: c11befff-9ea0-433c-b798-7b8b2871119e. Response code: 200

6Second message dispatched

DEBUG 2025-11-04 10:51:05,114

Message dispatched with ID: 767ed392-b4f7-47d9-9a75-d0704ccf7ead

7Third message received but queued (not yet dispatched)

DEBUG 2025-11-04 10:51:05,115

Message received with ID: d7fb2169-969f-4299-9c10-7dffd3b34561 and lock ID: AQEBrPzw4FFcvJ3wrcX….

8ACK triggered against the second message

DEBUG 2025-11-04 10:52:35,164

Sending DELETE request to https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1/organizations/<orgID>/environments/<envID>/destinations/testing-fifo/messages/767ed392-b4f7-47d9-9a75-d0704ccf7ead

DEBUG 2025-11-04 10:52:35,316

Received response from DELETE https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1/organizations/<orgID>/environments/<envID>/destinations/testing-fifo/messages/767ed392-b4f7-47d9-9a75-d0704ccf7ead. Request Id: 8cd9ebcf-9cf0-4076-8be1-d018245df935. Response code: 400

NOTE:

By this time, the lock on the second message has expired — the default lock duration in Anypoint MQ is typically 120 seconds (2 minutes).
If the message is not ACKed within this period, the lock becomes invalid, and Anypoint MQ ACK end with a 400 Bad Request.

9NACK triggered by error handler

DEBUG 2025-11-04 10:52:35,354

Sending DELETE request to https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1/organizations/<orgID>/environments/<envID>/destinations/testing-fifo/messages/767ed392-b4f7-47d9-9a75-d0704ccf7ead/locks/    AQEBpeUWnHhPYVUoFV5gBNMkwluz....2Fd8i9gStIm8Q20oe0J

DEBUG 2025-11-04 10:52:35,450
Received response from DELETE https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1/organizations/<orgID>/environments/<envID>/destinations/testing-fifo/messages/767ed392-b4f7-47d9-9a75-d0704ccf7ead/locks/    AQEBpeUWnHhPYVUoFV5gBNMkwluz....2Fd8i9gStIm8Q20oe0J. Request Id: 1197d9b5-9c0a-4166-8170-6808386dc17d. Response code: 400

 

SOLUTION

1.Increase TTL for the acknowledgementTimeout in the subscriber configuration. The default TTL is two minutes.

For example:

	<anypoint-mq:subscriber doc:name="Subscriber" doc:id="5100fdd2-752b-49bf-9d12-53409da59b4e" destination="testing-fifo" acknowledgementMode="MANUAL" config-ref="Anypoint_MQ_Config" acknowledgementTimeout="5" acknowledgementTimeoutUnit="MINUTES">
			<anypoint-mq:subscriber-type >
				<anypoint-mq:polling>
					<scheduling-strategy >
						<fixed-frequency />
					</scheduling-strategy>
				</anypoint-mq:polling>
			</anypoint-mq:subscriber-type>
		</anypoint-mq:subscriber>

 

2. Reduce the polling size. 

If the average or worst-case message processing time is relatively long, maintaining a polling size of 10 increases the likelihood of encountering lock ID expiration errors. This is because, with maxConcurrency=1, all 10 messages are fetched at once but processed sequentially — one message at a time due to the limitation set on the flow level.

By the time the first few messages are fully processed and an ACK is sent, the lock TTL for later messages may have already expired. This leads to the HTTP 400 – “LockId provided is expired” error when the ACK is attempted.

To prevent this, consider reducing the polling size (i.e 1 or 2) so that fewer messages are fetched per poll, aligning the total processing time with the lock duration.

Note:
This behavior is not a bug in the Anypoint MQ connector.
Messages are processed sequentially because maxConcurrency=1 is explicitly configured at the flow level, which limits parallel message handling.

3. Optimize or parallelize long-running operations where possible

4. Consider Queue Type & Concurrency Requirements

If parallel message processing is required, consider using a Standard queue with an increased maxConcurrency value.

While a FIFO queue technically allows maxConcurrency > 1 (for example, maxConcurrency=10), doing so means messages may not be processed in strict order. Since message ordering is the core feature of FIFO, maintaining maxConcurrency=1 is required to preserve guaranteed ordering. For more info, please refer to a KB Anypoint MQ FIFO Queue Message is not in order if maxConcurrency is not 1

 

 

Knowledge-artikkelnummer

005228013

 
Laster
Salesforce Help | Article