---
schema_version: "1"
id: 55844c4798d52cca0a711769bae3aa9e9f630bb7f83c031e00c4036869976ed9
title: Mule エラーハンドラーへの Exception Strategy (例外戦略) の移行
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-runtime/4.6/migration-core-exception-strategies.md
canonical_url: https://docs.mulesoft.com/jp/mule-runtime/4.6/migration-core-exception-strategies
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b7e5e4805ac4a6f2cd31ab29c204a300ff6d04b4691633127272ae538d3c534b
description: MuleSoft Documentation Site
release: "4.6"
latest: false
---
# Mule エラーハンドラーへの Exception Strategy (例外戦略) の移行

次の例で、Mule 3 のさまざまな Exception Strategy (例外戦略) の移行について説明し、Mule 4 の新しいエラー処理コンポーネントについて考えます。

<table><tbody><tr><td class="icon"><i class="fa icon-important" title="Important"></i></td><td class="content">これらの例では、​<code>when</code>​ 属性内で使用される式の移行については説明していません。 式の移行については​<a href="https://docs.mulesoft.com/jp/mule-runtime/4.6/migration-mel" class="xref page">「DataWeave への MEL の移行」</a>​、Java モジュールを使用して例外を分析する方法については​<a href="https://docs.mulesoft.com/jp/java-module/latest/java-throwable" class="xref page">「Throwable の使用」</a>​を参照してください。</td></tr></tbody></table>

## [](#catch-exception-strategy-キャッチ例外戦略)Catch Exception Strategy (キャッチ例外戦略)

catch exception strategy (キャッチ例外戦略) は、すべてのエラーを受け入れる単一の ​`on-error-continue`​ コンポーネントを使用するエラーハンドラーに相当します。これはデフォルトの設定です。

Mule 3 の例

```xml
<flow name="catch">
  <!-- flow logic -->
  <catch-exception-strategy>
    <!-- error handling logic -->
  </catch-exception-strategy>
</flow>
```

Mule 4 の例

```xml
<flow name="catch">
  <!-- flow logic -->
  <error-handler>
    <on-error-continue>
      <!-- error handling logic -->
    </on-error-continue>
  </error-handler>
</flow>
```

## [](#rollback-exception-strategy-ロールバック例外戦略)Rollback Exception Strategy (ロールバック例外戦略)

単純な (再配信のない) rollback exception strategy (ロールバック例外戦略) は、すべてのエラーを受け入れる単一の ​`on-error-propagate`​ コンポーネントを使用するエラーハンドラーに相当します。これはデフォルトの設定です。

Mule 3 の例

```xml
<flow name="rollback">
  <!-- flow logic -->
  <rollback-exception-strategy>
    <!-- error handling logic -->
  </rollback-exception-strategy>
</flow>
```

Mule 4 の例

```xml
<flow name="rollback">
  <!-- flow logic -->
  <error-handler>
    <on-error-propagate>
      <!-- error handling logic -->
    </on-error-propagate>
  </error-handler>
</flow>
```

## [](#再配信の指定)再配信の指定

- `idempotent-redelivery-policy`​ は ​`redelivery-policy`​ に名前が変更されます。
- `org.mule.runtime.core.api.exception.MessageRedeliveredException`​ は ​`REDELIVERY_EXHAUSTED`​ エラー種別に置き換わりました。
- `dead-letter-queue`​ は削除されます。DLQ にパブリッシュするために実行されるアウトバウンド操作は、​`REDELIVERY_EXHAUSTED`​ エラーの処理の一部として実行する必要があります。次に例を示します。
    
    Mule 3 の例
    
    ```xml
    <idempotent-redelivery-policy maxRedeliveryCount="${maxRedeliveryAttempts}">
        <dead-letter-queue>
            <http:request ... />
        </dead-letter-queue>
    </idempotent-redelivery-policy>
    ```
    
    Mule 4 の例
    
    ```xml
    <redelivery-policy maxRedeliveryCount="${maxRedeliveryAttempts}"/>
    
    ...
    
    <error-handler>
        <on-error-propagate type="REDELIVERY_EXHAUSTED">
            <http:request ... />
        </on-error-propagate>
    </error-handler>
    ```
- `rollback-exception-strategy`​ では ​`maxRedelivery`​ がサポートされなくなりました。​`maxRedelivery`​ を指定する ​`<redelivery-policy>`​ 要素は、​`message-source`​ 内に作成する必要があります。

## [](#choice-exception-strategy-選択肢例外戦略)Choice Exception Strategy (選択肢例外戦略)

内部に catch/rollback exception strategy (キャッチ/ロールバック例外戦略) を含む choice exception strategy (選択肢例外戦略) は、前述のとおり、例外戦略の種類に応じて on-error continue または on-error propagate を使用するエラーハンドラーに相当します。

Mule 3 の例

```xml
<flow name="choice">
  <!-- flow logic -->
  <choice-exception-strategy>
      <rollback-exception-strategy when="#[some_expression_here]">
          <!-- error handling logic -->
      </rollback-exception-strategy>
      <catch-exception-strategy/>
    </choice-exception-strategy>
</flow>
```

Mule 4 の例

```xml
<flow name="choice">
  <!-- flow logic -->
  <error-handler>
    <on-error-propagate when="#[some_expression_here]">
      <!-- error handling logic -->
    </on-error-propagate>
    <on-error-continue/>
  </error-handler>
</flow>
```

## [](#reference-exception-strategy-参照例外戦略)Reference Exception Strategy (参照例外戦略)

ガイドラインに従って前述の例外戦略はすでに移行されているので、実際の参照の移行は ​`error-handler`​ 参照を追加するだけです。

Mule 3 の例

```xml
<flow name="reference">
  <!-- flow logic -->
  <exception-strategy ref="referencedHandler"/>
</flow>
```

Mule 4 の例

```xml
<flow name="reference">
  <!-- flow logic -->
  <error-handler ref="referencedHandler"/>
</flow>
```

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

[エラーハンドラー](https://docs.mulesoft.com/jp/mule-runtime/4.6/error-handling)

[ブログ: A Look into Error Handling in Mule 4 Beta (Mule 4 ベータ版のエラー処理の調査)](https://blogs.mulesoft.com/dev/mule-dev/how-to-error-handling-mule-4-beta/)