Contact Us 1-800-596-4880

Configuring Mule Gateway API Autodiscovery in a Mule 3 Application

To configure API Autodiscovery in your Mule 3.x application, you must meet the following requirements:

Making your API Available in API Manager

The API to which you want to pair your Mule application must be available in API Manager.
You can either:

api name version autodiscovery

API Manager exposes the API Name and version that you generated in the tasks above.
These API Name and Version are required by the Autodiscovery element to identify the API to which you want to pair your application.

Configuring Anypoint Platform Organization Credentials in Mule Runtime

To use Autodiscovery in a Mule Application, the Runtime must start with Anypoint Platform credentials already configured.
Learn how to configure your organization credentials based on your deployment target in Configuring Organization Credentials in Mule Runtime 3.

Configuring the Autodiscovery Element in Your Mule Application

Within the code of your Mule Application, you must configure the api-gateway:auto-discovery element.
The Autodiscovery element points to the specific API in API Manager to which you want to pair.

If you configured a proxy endpoint for your API, your autogenerated proxy will already be correctly configured with the Autodiscovery element.
XML element
<api-platform-gw:api
  apiName="${apiName}" (1)
  version="${apiVersion}" (2)
  flowRef="proxy" (3)
  apikitRef="api-config"/> (4)
1 Configure the ${apiName} with the UUID, which is the group ID and the Exchange asset ID assigned to your API by API Manager.
2 Configure the ${apiVersion} with the API Version, which is the version name and the instance ID or the label assigned to your API by API Manager.
3 Set the flowRef element to point to the flow that you want to pair to the API in API Manager.
4 If you use APIkit and you would like to apply policies at a resource level, you must set this value. Otherwise said policies won’t work at resource level.

You can either replace ${apiName} and ${apiVersion} with your specific value, or you can create a config.properties file where you define it in a key-value fashion: apiName=[your-specific-value] and reference it as ${apiName} and ${apiVersion} in this configuration.

You can also configure this using Anypoint Studio’s UI:

  1. In your existing flow, select the Global Elements tab in your Mule Configuration File editor.

  2. Click the Create button, and look for the API Autodiscovery global element.

    autodis cerate global2
  3. Set the APIname, version, and Flow Reference.

    autodis choose global2

    You can also choose to use the ${apiName} and ${apiVersion} value and reference it from a config.properties file.

After the element is defined in the application, and the runtime is configured with your Anypoint Platform credentials, Mule Runtime will automatically track and keep up to date with the API configuration. defined in API Manager.