---
schema_version: "1"
id: f206ec4cb7d986747b99562a75cf0c55edfceba65fc11168b3ea5047fc64867a
title: Configure Message Acknowledgement with the JMS Connector
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/jms-connector/latest/jms-ack.md
canonical_url: https://docs.mulesoft.com/jms-connector/latest/jms-ack
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 02b12c3b10cbcb27d67303debd8c0215aa95251374b38862240eb68b7e7d92f2
description: MuleSoft Documentation Site
release: "2.0"
latest: true
---
---
product: JMS Connector
version: 2.0
is-latest-version: true
keywords: jms, connector, consume, message, ack
---

# Configure Message Acknowledgement with the JMS Connector

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

Anypoint Connector for JMS (JMS Connector) provides different message acknowledgement modes to
configure for the **Ack**, **Consume**, **On New Message**, and **Recovery session** operations:

- Automatic acknowledgement on success

- Immediate acknowledgement

- Manual acknowledgement

The following examples illustrate how to configure each message acknowledgement mode.

## Configure Automatic Acknowledgement on Success Mode

Configure the automatic acknowledgement on success mode in the **On New Message** source by setting
the **Acknowledge Mode** field to either one of these modes:

- **AUTO**  
  Automatically acknowledges (ACK) the received message only if the flow execution completes
  successfully; otherwise, the message is not acknowledged and is redelivered.

- **DUPS\_OK**  
  Like **AUTO** mode, automatically acknowledges (ACK) the received message only if the flow
  execution completes successfully, but leads to duplicate messages if the message is redelivered
  before the ACK is performed.

In the following example, you configure the **AUTO** acknowledgement mode:

1.  In Studio, select the **On New Message** source from your flow.

2.  In the **On New Message** configuration screen, in **Destination**, specify the name of the
    destination from which to consume the message, for example, `#[vars.destination]`.

3.  From the **Acknowledge Mode** menu, select **AUTO**.

![In the On New Message source screen](/mulesoft/current/en-us/jms-connector/latest/_images/jms-ack-auto.png)

Figure 1. JMS Connector Auto Acknowledgement Mode configuration

In the XML editor, the `<jms:listener>` and `ackMode` configurations look like this:

```xml
<jms:listener  config-ref="JMS_Config" destination="#[vars.destination]" ackMode="AUTO"/>
```

## Configure Immediate Acknowledgement Mode

Configure the immediate acknowledgement mode in the **On New Message** source by using the
**Acknowledge Mode** field, or in the **Consume** operation by using the **Ack mode** field. Set the
fields to **IMMEDIATE**. This mode automatically acknowledges (ACK) the message after it is consumed
and before to any application processing of the message.  
The result of automatically acknowledging the message is that the message won’t be redelivered if
any error occurs during message processing, requiring application logic like a "dead letter" queue
to manage errors without losing messages.

In the following example, you configure the **IMMEDIATE** acknowledgement mode for the **Consume**
operation:

1.  In Studio, select the **Consume** operation from your flow.

2.  In the **Consume** configuration screen, in **Destination**, specify the name of the destination
    from which to consume the message, for example, `#[vars.destination]`.

3.  From the **Ack mode** menu, select **IMMEDIATE**.

![In the Consume operation screen](/mulesoft/current/en-us/jms-connector/latest/_images/jms-ack-immediate.png)

Figure 2. JMS Connector Immediate Acknowledgement Mode configuration

In the XML editor, the `<jms:consume>` and `ackMode` configurations look like this:

## Configure Manual Acknowledgement Mode

Configure the manual acknowledgement mode in the **On New Message** source by using the
**Acknowledge Mode** field, or in the **Consume** operation by using the **Ack mode** field. Set
these fields to **MANUAL**. This mode delegates all responsibility for performing message
acknowledgement (ACK) to the application logic.

Every message received by either the **On New Message** or **Consume** operations includes an
acknowledgement ID in the Mule message attributes, that identifies the message uniquely for a given
connection.  
The acknowledgement ID that identifies the message is then passed to the **Ack** operation in the
**Ack id** field.

In the following example, you configure the **MANUAL** acknowledgement mode for the **Consume**
operation:

1.  In Studio, select the **Consume** operation from your flow.

2.  In the **Consume** configuration screen, in **Destination**, specify the name of the destination
    from which to consume the message, for example, `openTickets`.

3.  From the **Ack mode** menu, select **MANUAL**.

4.  Drag a **Logger** component to the right of the **Consume** operation.

5.  Set the **Message** field to `#[payload]`.

6.  Drag an **Ack** operation to the right of the **Logger** component.

7.  Set the **Ack id** field to the acknowledgement ID of the message session to recover, for
    example, `#[attributes.ackId]`.

![In the Ack operation screen](/mulesoft/current/en-us/jms-connector/latest/_images/jms-ack-operation.png)

Figure 3. JMS Connector Ack operation configuration

In the XML editor, the `<jms:consume>`, `ackMode`, and `ackId` configurations look like this:

```xml
<flow name="consumerWithManualAck">
    <jms:consume config-ref="JMS_config" destination="openTickets" ackMode="MANUAL"/>

    <!--Do message processing-->
    <logger message="#[payload]">

    <jms:ack ackId="#[attributes.ackId]"/>
</flow>
```

### Configure Manual Session Recovery

With manual acknowledgement mode, all messages received but not acknowledged are not redelivered by
the broker. If there is an error during the message processing, you must manually recover all the
messages in the session that have to be redelivered by using the **Recover session** operation. The
connection used to recover the session has to be the same as the connection for receiving the
message.

In the following example, you configure the **MANUAL** acknowledgement mode and how to recover the
session:

1.  In Studio, select the **Consume** operation from your flow.

2.  In the **Consume** configuration screen, in **Destination**, specify the name of the destination
    from which to consume the message, for example, `${destination}`.

3.  Set the **Ack mode** field to **MANUAL**.

4.  Drag a **Logger** component to the right of the **Consume** operation.

5.  Set the **Message** field to `#[payload]`.

6.  Drag an **Ack** operation to the right of the **Logger** component.

7.  Set the **Ack id** field to the acknowledgement ID of the message session to recover, for
    example, `#[vars.consumedMessage.attributes.ackId]`.

8.  In your flow, expand the **Error handling** section by clicking the small arrow.

9.  Drag an **On Error Propagate** component in the **Error handling** section.

10. Drag a **Recover session** operation inside the **On Error Propagate** component.

11. Set the **Ack id** field to `#[vars.consumedMessage.attributes.ackId]`.

![In the Recover session operation screen](/mulesoft/current/en-us/jms-connector/latest/_images/jms-ack-recover.png)

Figure 4. JMS Connector Recover session operation configuration

In the XML editor, the `<jms:consume>`, `ackMode`, and `ackId` configurations look like this:

```xml
<flow name="consumerWithManualAck">
    <jms:consume config-ref="JMS_config" destination="${destination}"
                 ackMode="MANUAL" target="consumedMessage" targetValue="#[message]"/>

    <!--Do message processing-->
    <logger message="#[payload]">

    <jms:ack ackId="#[vars.consumedMessage.attributes.ackId]"/>

    <error-handler>
        <on-error-continue>
            <!--In case of error, recover the session-->
            <jms:recover-session ackId="#[vars.consumedMessage.attributes.ackId]"/>
        </on-error-continue>
    </error-handler>
</flow>
```

## See Also

- [Configure Topic Subscriptions](https://docs.mulesoft.com/jms-connector/latest/jms-topic-subscription)

- [Listen for New Messages](https://docs.mulesoft.com/jms-connector/latest/jms-listener)
