Troublehooting mule autodiscovery issues

In MuleSoft you have the possibility to configure autodiscovery. The autodiscovery feature allows a mule runtime to be paired during deployment with the API Management portal. After you have paired the application you have the ability to enforce policies and have access to tracking information.

This feature is pretty well documented on how to configure autodiscovery but sometimes you can get in trouble configuring this feature. This can especially be true when you need to connect to the EU control plane instead of the default US management plane.

In our case we were having the following errors in the runtime we deployed to cloudhub:

13:55:20.408 05/29/2018 Worker-0 agw-api-platform-connection-retry.01 ERROR Client ID and Client Secret could not be validated against API Manager.
13:53:28.696 05/29/2018 Worker-0 qtp1277242916-38 INFO API ApiKey{id=’xxxxx’} is blocked (unavailable).

So we needed to find out which POM settings were needed in order for the application to register itself under the API Manager. We did find some POM settings that enabled our Mule 3.x application to register itself. But apparently we needed different POM settings for Mule 4 application.

The best way to troubleshoot this issue to let the Anypoint Platform itself figure out which settings are needed. Let’s assume you already have an application in the API Management section. (Read this post on howto deploy an application with Maven).

Go to the API Manager and select your application:

API Manager

Now go and configure an endpoint Proxy for this application.
Just add a fictitious implementation url. The deployment does not to succeed.

API Configuration

Select a deployment configuration for the Proxy application. And click deploy.

Deployment configuration

It’s ok for the deployment to fail. Mulesoft had already created a runtime on the background with the correct proxy settings we need.

Deployment

When you go to Runtime Management, you will see that an runtime application has been created. As you can see in the screenshot here are the settings we need to configure in the Maven POM files.

Runtime Manager

Now we can remove the runtime that Mulesoft created and reverse the settings we made in the API Manager.

For Mule 3.x use the settings as displayed in the POM below:

<build>
 <plugins>
  <plugin>
   <groupId>org.mule.tools.maven</groupId>
   <artifactId>mule-<u>maven</u>-<u>plugin</u></artifactId>
   <version>${mule.tools.version}</version>
    <configuration>
     <inclusions>
     <inclusion>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-apikit-soap</artifactId>
     </inclusion>
     <inclusion>
   <groupId>org.mule.modules</groupId>
   <artifactId>mule-module-sfdc</artifactId>
   </inclusion>
   </inclusions>
   <deploymentType>cloudhub</deploymentType>
   <muleVersion>${mule.version}</muleVersion>
   <username>${muleUsername}</username>
   <password>${mulePassword}</password>
   <redeploy>true</redeploy>
   <environment>${env}</environment>
   <applicationName>${env}-${project.name}</applicationName>
   <businessGroup>your business group\BG</businessGroup>
   <region>eu-central-1</region>
   <uri>https://eu1.anypoint.mulesoft.com</uri>
   <workerType>Micro</workerType>
   <properties>
    <anypoint.platform.analytics_base_uri>https://eu1.analytics-ingest.anypoint.mulesoft.com</anypoint.platform.analytics_base_uri>
    <anypoint.platform.coreservice_base_uri>https://eu1.anypoint.mulesoft.com/accounts</anypoint.platform.coreservice_base_uri>
    <anypoint.platform.platform_base_uri>https://eu1.anypoint.mulesoft.com/apiplatform</anypoint.platform.platform_base_uri>
    <anypoint.platform.contracts_base_uri>https://eu1.aanypoint.mulesoft.com/apigateway/ccs</anypoint.platform.contracts_base_uri>
    <anypoint.platform.client_id>************</anypoint.platform.client_id>
    <anypoint.platform.client_secret>************</anypoint.platform.client_secret>
    <env>${env}</env>
   </properties>
  </configuration>
  <executions>
  <execution>
  <id>deploy</id>
  <phase>deploy</phase>
  <goals>
  <goal>deploy</goal>
  </goals>
  </execution>
  </executions>
 </plugin>
</plugins>

For Mule 4.x use the settings as displayed in the POM below:


<plugin>
 <groupId>org.mule.tools.maven</groupId>
 <artifactId>mule-<u>maven</u>-<u>plugin</u></artifactId>
 <version>${mule.maven.plugin.version}</version>
 <extensions>true</extensions>
 <configuration>
 <cloudHubDeployment>
  <uri>https://eu1.anypoint.mulesoft.com</uri>
  <muleVersion>${app.runtime}</muleVersion>
  <username>${muleUsername}</username>
  <password>${mulePassword}</password>
  <applicationName>>${env}-${project.name}</applicationName>
  <businessGroup> your business group\BG </businessGroup>
  <region>eu-west-1</region>
  <environment>${env}</environment>
  <workerType>Micro</workerType>
  <workers>1</workers>
  <properties>
   <anypoint.platform.analytics_base_uri>https://analytics-ingest.eu1.anypoint.mulesoft.com</anypoint.platform.analytics_base_uri>
   <anypoint.platform.client_id>************</anypoint.platform.client_id>
   <anypoint.platform.client_secret>************</anypoint.platform.client_secret>
   <anypoint.platform.base_uri>https://eu1.anypoint.mulesoft.com</anypoint.platform.base_uri>
  </properties>
  </cloudHubDeployment>
 </configuration>
</plugin>

Of course you will also need to add the autodiscovery feature to the project.
Hopefully this fixes your Mulesoft autodiscovery issues.

One Reply to “Troublehooting mule autodiscovery issues”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.