Contact Us 1-800-596-4880

Applying Offline Custom Policies

An offline policy is applied directly to the runtime and not through API Manager. When you create a file in the offline-policies directory, Mule runtime engine (Mule) detects the presence of the file and starts applying the policy.

Mule then generates the JSON and XML policy files in a new directory in %MULE_HOME%/policies.

Task Prerequisites

Before you apply an offline custom policy, ensure that:

  • Mule runtime engine (Mule) is installed with Mule Gateway capabilities enabled.

  • An API configured with a basic endpoint or a proxy endpoint exists in API Manager.

  • A Mule application is deployed with a HTTP(s) based flow, which is linked to the API through Autodiscovery.

    When Autodiscovery is correctly configured in your Mule application, your application’s API is said to be tracked by or paired to API Manager.

Apply an Offline Custom Policy

To apply an offline custom policy:

  1. If you do not want to use the policy template from Exchange due to various reasons, place the template JAR in the following directory before you apply the offline policy to the API.

    %MULE_HOME%/policies/policy-templates

  2. Create a JSON file in %MULE_HOME%/policies/offline-policies directory that defines the policy configuration.

  3. Name the JSON file after the policy ID.

  4. In the file, include the following configuration specifications:

    • Policy template information

      Specify the Exchange groupId, assetId, and version of the template used to deploy the offline policy definition.

    • IDs of the APIs that the policy will be applied to

    • A list of resources that the policy will be applied to

    • Order of the policy

    • Parameters if the defined template is using handlebars variables

      The following example shows a typical offline policy definition:

      {
       "template" : {
         "groupId" : "com.mulesoft.anypoint",
         "assetId" : "policyTemplate",
         "version" : "0.1.0"
       },
       "api": [
         {
           "id": "1"
         },
         {
           "id": "2"
         }
       ],
       "order": 1,
       "configuration" : {
         "payload" : "Payload"
       }
      }
  5. After you apply a custom offline policy, you must manually deploy it to a Mule runtime engine (Mule) file system.