---
schema_version: "1"
id: 71767562f0809e266702eb225362a5728a3ce5dce0603c444a30eaaeb347059e
title: Until Successful (<until-successful/>)
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/anypoint-code-builder/acb-component-until-successful.md
canonical_url: https://docs.mulesoft.com/jp/anypoint-code-builder/acb-component-until-successful
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c8a4eae138ea42923f1ae3899dec2f26e977f178048352e589e368ffc45e2fb0
description: MuleSoft Documentation Site
latest: true
---
# Until Successful (<until-successful/>)

そのスコープ内のプロセッサーがすべて成功するか、またはスコープが最大再試行回数に達するまで、プロセッサーを順番に処理します。

Until Successful は同期的に実行されます。スコープ内のプロセッサーが接続に失敗したり、正常に結果を生成できなかったりした場合、Until Successful では設定されている最大再試行回数まで、失敗したプロセッサーを含めて内部のすべてのプロセッサーをやり直します。再試行が成功すると、スコープは次のコンポーネントに進みます。最後の再試行に失敗すると、Until Successful はエラーをスローします。

例外が発生しない場合、または応答が式に一致する場合、ルーティングは成功です。

Until Successful を使用する一般的な処理は次の通りです。

- アウトバウンドエンドポイントへのディスパッチ (可用性に問題があるかも知れないリモート Web サービスを呼び出す場合など)。
- コンポーネントメソッドの実行 (信頼性の低いリソースに依存する Spring bean を実行する場合など)。
- Subflow コンポーネント (​`<sub-flow/>`​) を使用した、いくつかのアクションが成功するまでの再試行。

## [](#component-xml)コンポーネント XML

このコンポーネントは、次の XML 構造をサポートします。

```xml
<until-successful
  doc:name="Until successful"
  doc:id="mbqhsp" >
  <!-- Components to execute inside the scope -->
</until-successful>
```

Until Successful (​`<until-successful/>`​) 属性は UI および XML で設定できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性名</th>
<th class="tableblock halign-left valign-top">属性 XML</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Until successful (成功するまで)</strong>​ (デフォルト)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>doc:name</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>キャンバスに表示されるコンポーネントの編集可能な名前。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">なし</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>doc:id</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>コンポーネントの自動生成された識別子。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Max retries (最大再試行回数)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>maxRetries</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>許可される再試行の最大数。この属性は、数値、または数値に解決される式にできます。最大回数に達すると、​<code>Message: 'until-successful' retries exhausted.</code>​ のようなエラーメッセージが出力されます。Mule エラー種別は ​<code>MULE:RETRY_EXHAUSTED</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Millis between retries (再試行間のミリ秒数)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>millisBetweenRetries</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>再試行から次の再試行を実行するまでの最小間隔をミリ秒で指定します。間隔の長さは前回の実行の影響を受けますが、通常は最小値の 2 倍を超えることはありません。この属性は、数値、または数値に解決される式にできます。デフォルトは ​<code>60000</code>​ ミリ秒 (1 分) です。</p>
</div></div></td>
</tr>
</tbody>
</table>

## [](#変数の伝播)変数の伝播

最大再試行回数に達する前にスコープ内でエラーが発生した場合でも、Until Successful スコープは毎回必ず、ブロックの実行前に存在していた変数と値を使用して実行が開始されます。1 つの要素の処理中の新しい変数や既存の変数への修正は、スコープの実行時には表示されません。実行が正常に完了すると、変数 (およびペイロード) はフローの残り部分に伝播されます。

## [](#until-successful-スコープの設定例)Until Successful スコープの設定例

次の XML の例では、Scheduler コンポーネントによりトリガーされるフローと、FTP Write 操作を実行する Until Successful スコープを設定します。

```xml
<!-- FTP Connector config-->
<ftp:config name="FTP_Config" doc:name="FTP Config" >
  <ftp:connection workingDir="${ftp.dir}" host="${ftp.host}" />
</ftp:config>

<flow name="untilSuccessfulFlow" >
  <!-- Scheduler component to trigger the flow-->
  <scheduler doc:name="Scheduler" >
    <scheduling-strategy >
      <fixed-frequency frequency="15" timeUnit="SECONDS"/>
    </scheduling-strategy>
  </scheduler>
  <!-- Until Successful scope-->
  <until-successful maxRetries="5" doc:name="Until Successful" millisBetweenRetries="3000">
    <!-- FTP Write operation that executes as part of the Until Successful Scope -->
    <ftp:write doc:name="Write" config-ref="FTP_Config" path="/"/>
  </until-successful>
  <logger level="INFO" doc:name="File upload success" message="File upload success"/>
  <!-- Error Handler at flow level-->
  <error-handler>
    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" type="RETRY_EXHAUSTED">
      <logger level="INFO" doc:name="File upload failed" message="File upload failed"/>
    </on-error-continue>
  </error-handler>
</flow>
```

サンプルアプリケーションの動作:

- FTP Write 操作が失敗した場合、Until Successful スコープでは、操作が成功するまで ​`3000`​ ミリ秒ごとに操作を再試行します。ただし、​`5`​ 回の再試行回数の制限があります。
    
    最後の実行が失敗すると ​`MULE:RETRY_EXHAUSTED`​ エラーがスローされます。次に、​`<on-error-continue>`​ でエラーが処理され、Logger が実行されて、​`File upload failed`​ というメッセージが表示されます。
    
    `MULE:RETRY_EXHAUSTED`​ をスローする前に、Mule では、たとえば次のように、Mule イベントでプロセッサーの実行をやり直すために失敗した各試行をログにも記録します。
    
    ```logs
    ERROR 2022-12-09 17:41:44,910 ... event: cdad31c0-782b-11ed-af21-147ddaaf4f97]
    ...UntilSuccessfulRouter: Retrying execution of event, attempt 1 of 5.
    ...
    ERROR 2022-12-09 17:41:55,079 ... event: cdad31c0-782b-11ed-af21-147ddaaf4f97]
    ...UntilSuccessfulRouter: Retrying execution of event, attempt 5 of 5.
    ```
- いずれかの試行で FTP Write 操作の実行が成功した場合、Until Successful スコープの後の次のプロセッサーが実行されます。この例では、Logger が実行され、​`File upload success`​ というメッセージが表示されます。

## [](#see-also)関連情報

- [トランザクションによるスコープとルーターへの影響](https://docs.mulesoft.com/mule-runtime/latest/transaction-management#tx_scopes_routers)