+

Migrating API Gateways: Autodiscovery

Standard Support for Mule 4.2 ended on May 2, 2021, and this version of Mule will reach its End of Life on May 2, 2023, when Extended Support ends.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

The Autodiscovery element was updated after Mule 4 release.

  • APIs are referenced by an ID instead of a name and version.

  • Creation of APIs from the runtime is no longer possible.

Simple Mule app with an HTTP listener and an Autodiscovery element defined:

Mule 3 Example: All Configurable Attributes
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:api-platform-gw="http://www.mulesoft.org/schema/mule/api-platform-gw"
      xmlns:http="http://www.mulesoft.org/schema/mule/http"
      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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
       http://www.mulesoft.org/schema/mule/api-platform-gw http://www.mulesoft.org/schema/mule/api-platform-gw/current/mule-api-platform-gw.xsd">

    <api-platform-gw:api id="apiId" create="true" apiName="name" version="1.0.0" flowRef="flow_api">
        <api-platform-gw:description>This is a test API</api-platform-gw:description>
        <api-platform-gw:tag>tag1</api-platform-gw:tag>
        <api-platform-gw:tag>tag2</api-platform-gw:tag>
    </api-platform-gw:api>

    <http:listener-config name="httpConfig" host="localhost" port="${port}" />

    <flow name="flow_api">
        <http:listener config-ref="httpConfig" path="api" />
        <logger message="Executing empty" level="INFO"/>
    </flow>

</mule>
Mule 4 Example: All Configurable Attributes
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns:api-gateway="http://www.mulesoft.org/schema/mule/api-gateway"
      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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
       http://www.mulesoft.org/schema/mule/api-gateway http://www.mulesoft.org/schema/mule/api-gateway/current/mule-api-gateway.xsd">

    <api-gateway:autodiscovery apiId="1" flowRef="flow_api" />

    <http:listener-config name="httpConfig" basePath="api">
        <http:listener-connection host="localhost" port="${port}"/>
    </http:listener-config>

    <flow name="flow_api">
        <http:listener config-ref="httpConfig" path="api" />
        <logger message="Executing empty" level="INFO"/>
    </flow>

</mule>
Was this article helpful? Thanks for your feedback!
View on GitHub