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

いずれかのルートが正常に実行されるまで、設定されている処理ルートのリストのルートを反復処理します。

1 つの処理ルートが実行に失敗すると (エラーをスローします)、ルーターは次に設定されているルートを実行します。

設定されているルートがいずれも正常に実行されないと、First Successful ルーターはエラーをスローします。

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

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

```xml
<first-successful
  doc:name="First successful"
  doc:id="vyaedo" >
  <!-- First Route -->
  <route>
    <!-- Processors -->
  </route>
  <!-- Second Route -->
  <route>
    <!-- Processors -->
  </route>
</first-successful>
```

First Successful (​`<first-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>First 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>
</tbody>
</table>

`<route/>`​ は First Successful の子要素です。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">子要素</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&lt;route/&gt;</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>1 つ以上のコンポーネントを子要素として受け入れます。複数の ​<code>&lt;route/&gt;</code>​ 設定が許可されます。</p>
</div></div></td>
</tr>
</tbody>
</table>

## [](#例)例

4 つの処理ルートが設定されている First Successful ルーターの例を示します。

```xml
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:sockets="http://www.mulesoft.org/schema/mule/sockets"
  xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
  xmlns:db="http://www.mulesoft.org/schema/mule/db"  xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
                            http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
                            http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
                            http://www.mulesoft.org/schema/mule/sockets http://www.mulesoft.org/schema/mule/sockets/current/mule-sockets.xsd
                            http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
  <http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="b026579b-5a59-444f-8f91-ff209bed8342" >
    <http:request-connection >
      <http:client-socket-properties >
        <sockets:tcp-client-socket-properties connectionTimeout="500" clientTimeout="500" />
      </http:client-socket-properties>
    </http:request-connection>
  </http:request-config>
  <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4631e4fd-571f-41c8-831d-d908b1763ef2" >
    <http:listener-connection host="localhost" port="8081" />
  </http:listener-config>
  <flow name="testFlow" doc:id="79cd7fcd-d355-418b-898b-5d7e3a1cbcab" >
    <scheduler doc:name="Scheduler" doc:id="6dc5dcc7-ce33-4d18-9de9-2c665f713508" >
      <scheduling-strategy >
        <fixed-frequency />
      </scheduling-strategy>
    </scheduler>
    <first-successful doc:name="First Successful" doc:id="6ae009e7-ebe5-47cf-b860-db6d51a31251" >
      <route> (1)
        <file:read doc:name="Read non existent file" doc:id="199cdb01-cb43-404e-acfd-211fe5a9167e" path="nonExistentFile"/>
        <set-variable value="1" doc:name="Set successfulRoute var to route 1" doc:id="c740b39e-a1c4-41d6-8a28-0766ca815ec6" variableName="successfulRoute"/>
      </route>
      <route> (2)
        <set-payload value="#[vars.nonExistentVar!]" doc:name="Set Payload with non existent variable" doc:id="0cc9ac4d-5622-4e10-971c-99073cb58df0" />
        <set-variable value="2" doc:name="Set successfulRoute var to route 2" doc:id="88f15c26-d242-4b11-af49-492c35625b84" variableName="successfulRoute" />
      </route>
      <route> (3)
        <set-variable value="3" doc:name="Set successfulRoute var to route 3" doc:id="446afb25-0181-45e5-b04a-68ecb98b57b7" variableName="successfulRoute" />
      </route>
      <route > (4)
        <logger level="INFO" doc:name="Logger" doc:id="b94b905a-3a68-4c88-b753-464bc3d0cfeb" message="This route is never going to be executed"/>
      </route>
    </first-successful>
    <logger level="ERROR" doc:name="Logger" doc:id="9ffe328d-2595-4f28-81e8-ae731fc6cb89" message="#['Successful route was $(vars.successfulRoute)']"/>
  </flow>
</mule>
```

<table><tbody><tr><td><i class="conum" data-value="1"></i><b>1</b></td><td>最初のルートが実行され、存在しないファイルを読み取ろうとしたため失敗します。</td></tr><tr><td><i class="conum" data-value="2"></i><b>2</b></td><td>2 つ目のルートは、存在しない変数にアクセスしようとしたため失敗します。</td></tr><tr><td><i class="conum" data-value="3"></i><b>3</b></td><td>3 つ目のルートは正常に実行され、​<code>successfulRoute</code>​ 変数に ​<code>3</code>​ を設定します。</td></tr><tr><td><i class="conum" data-value="4"></i><b>4</b></td><td>First Successful ルーターは、いずれかのルートが正常に完了した時点で実行を終了するため、4 つ目のルートは実行されません。</td></tr></tbody></table>

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

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