---
schema_version: "1"
id: 54c15007ac05bf7346527fac6929302f8a513f3da09c048b6a6a4ef0561b26a0
title: Choice ルーターの移行
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-runtime/4.4/migration-core-choice.md
canonical_url: https://docs.mulesoft.com/jp/mule-runtime/4.4/migration-core-choice
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e9a5f80871908633fd8c3a43caa55b6dce0b0fd6aa72855317f456de0a35a397
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
# Choice ルーターの移行

次を除き、Mule 3 と Mule 4 の Choice ルーターはほとんど変更されていません。

- DataWeave が式言語となり、when ステートメントで MEL の代わりに実際に使用されます。
- `<otherwise>`​ ブロックは省略可能になりました。

## [](#when-ブロックの式言語)when ブロックの式言語

when 式は MEL から DataWeave に変更する必要があります。これは、あらゆる形式を解釈する DataWeave の機能を利用し、必要のない変換を回避できることを意味します。たとえば、ユーザーを表す JSON ドキュメントが HTTP 経由で投稿されるフローがあり、そのユーザーが未成年かどうかを確認する必要があるとします。

Mule 3 の例: 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>
```

Mule 4 では、形式が JSON か Java かを気にする必要はなく、ただ次を実行します。

Mule 4 の例: 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>
```

## [](#省略可能な-otherwise)省略可能な otherwise

Mule 3 では ​`<otherwise>`​ ブロックは必須でした。代替ロジックが不要だった場合、​`<otherwise>`​ ブロックに含まれるのは重要ではないロガーになることが多々ありました。Mule 4 では ​`<otherwise>`​ ブロックは省略可能で、必要ない場合は指定する必要がありません。

## [](#関連情報)関連情報

[Mule 4 の概要: エラーハンドラー](https://docs.mulesoft.com/jp/mule-runtime/4.4/intro-error-handlers)

[MEL から DataWeave への移行](https://docs.mulesoft.com/jp/mule-runtime/4.4/migration-mel)

[DataWeave 1.0 から 2.x への移行](https://docs.mulesoft.com/jp/mule-runtime/4.4/migration-dataweave)