---
schema_version: "1"
id: 2f6df3a409523d8a50ec80a61e5269f996731f5d85d9058eaabe22a51e666215
title: Migrating the Choice Router
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/migration-core-choice.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/migration-core-choice
source_site: docs.mulesoft.com
content_type: documentation
content_hash: af86d30455079607a1e390c26c3ada9df3ef765d273c9012997793f24f927e53
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
---

# Migrating the Choice Router

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

Little changed between Choice router for Mule 3 and Mule 4 except for:

- DataWeave is now the expression language so the when statements are actually going to use it
  instead of MEL

- The `<otherwise>` block is now optional

## Expression Language for the When Block

The when expressions need to be changed from MEL to DataWeave. This also mean that you can leverage
DataWeave’s ability to interpret any format to avoid unnecessary convertions. For example, suppose a
flow in which a JSON document representing a user is posted through HTTP and you want to check if
the person is underage:

Mule 3 Example: MEL

```xml
<flow name="checkAge">
  <http:listener path="person" method="POST" config-ref="http" />
  <json:json-to-object-transformer />
  <choice>
    <when expression="#[payload.age > 21]">
      <logger message="adult" />
    </when>
    <otherwise>
      <logger message="underage" />
    </otherwise>
  </choice>
</flow>
```

With Mule 4, you don’t need to worry about JSON or Java formats and just do:

Mule 4 Example: DataWeave 2

```xml
<flow name="checkAge">
  <http:listener path="person" method="POST" config-ref="http" />
  <choice>
    <when expression="#[payload.age > 21]">
      <logger message="adult" />
    </when>
    <otherwise>
      <logger message="underage" />
    </otherwise>
  </choice>
</flow>
```

## Optional Otherwise

In Mule 3, the `<otherwise>` block was required. Many times in which fallback logic was not
necessary, you ended up with an `<otherwise>` block which just had an insignificant logger. In Mule
4, the `<otherwise>` block is optional and you don’t need to specify it if not necessary.

## See Also

[Introduction to Mule 4: Error Handlers](https://docs.mulesoft.com/mule-runtime/4.4/intro-error-handlers)

[Migrating from MEL to DataWeave](https://docs.mulesoft.com/mule-runtime/4.4/migration-mel)

[Migrating from DataWeave 1.0 to 2.x](https://docs.mulesoft.com/mule-runtime/4.4/migration-dataweave)
