---
schema_version: "1"
id: e0c6f227e6d15b47ba382d627211725c244edc3dc82a74d1fbdb17ab6b129234
title: First Successful (<first-successful/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-first-successful.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-first-successful
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0b00f24fe7272762d20d00c1106bad9288aa59d2c8e89b414ba66123f1137fce
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# First Successful (<first-successful/>)

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

Iterates through a list of configured processing routes until one of the routes executes
successfully.

If any processing route fails execution (throws an error), the router executes the next configured
route.

If none of the configured routes execute successfully, the First Successful router throws an error.

## Component XML

This component supports the following XML structure:

```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/>`) attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>First successful</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr></tbody></table>

`<route/>` is a child element of First Successful.

<table><colgroup><col> <col></colgroup><thead><tr><th>Child Element</th><th>Description</th></tr></thead><tbody><tr><td><p><code>&lt;route/&gt;</code></p></td><td><div><div><p>Accepts one or more components as child elements. Multiple <code>&lt;route/&gt;</code> configurations are allowed.</p></div></div></td></tr></tbody></table>

## Example

The following example shows a First Successful router configured with four processing routes:

```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 data-value="1"></i><b>1</b></td><td>The first route executes and fails because it tries to read a file that does not exist.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>The second route fails because it tries to access a variable that does not exist.</td></tr><tr><td><i data-value="3"></i><b>3</b></td><td>The third route executes successfully and sets variable <code>successfulRoute</code> with value <code>3</code>.</td></tr><tr><td><i data-value="4"></i><b>4</b></td><td>The fourth route is not executed because the First Successful router stops executing routes after one of them completes successfully.</td></tr></tbody></table>

## See Also

- [Mule Errors](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept)

- [Error Handlers](https://docs.mulesoft.com/mule-runtime/latest/error-handling)
