Loading

How to Configure JVM Arguments via API to RTF Applications

Publiceringsdatum: Aug 4, 2025
Steg

QUESTION

We are able to set the JVM in runtime manager UI and it is working perfectly fine.
We also want to configure the JVM param as part of the CICD application deployment.

The latest maven plugin 3.4.0 as of the date of this article does not support configure JVM arguments via maven. How can we set these JVM arguments as part of runtime fabric deployment?

ANSWER

You can configure the JVM arguments via the AMC Application Manager API with a PATCH request. 
> PATCH_REQUEST='{
  "id": "bbbe1236-6ef5-11ea-96c5-4fb8b4512917",
  "name": "demoapp",
  "creationDate": 1585181228406,
  "lastModifiedDate": 1590451582016,
  "target": {
    "provider": "MC",
    "targetId": "274fbbcb-b56f-4b28-a209-8c21cae2e75b",
    "deploymentSettings": {
      "jvm": {
        "args": "-Djavax.net.ssl.keyStore=/opt/mule/apps/demoapp/mykeystore.jks -Djavax.net.ssl.keyStorePassword=123456"
      },
      "http": {
        "inbound": {
          "publicUrl": "rtf.mulesoft.com/demoapp"
        }
      },
      "sidecars": {
        "anypoint-monitoring": {
          "image": "auto",
          "resources": {
            "cpu": {
              "limit": "50m",
              "reserved": "0m"
            },
            "memory": {
              "limit": "50Mi",
              "reserved": "50Mi"
            }
          }
        }
      },
      "clustered": false,
      "resources": {
        "cpu": {
          "limit": "1700m",
          "reserved": "20m"
        },
        "memory": {
          "limit": "700Mi",
          "reserved": "700Mi"
        }
      },
      "runtimeVersion": "4.2.2:v1.2.55",
      "updateStrategy": "rolling",
      "lastMileSecurity": false
    },
    "replicas": 1
  },
  "status": "APPLIED",
  "application": {
    "status": "RUNNING",
    "desiredState": "STARTED",
    "ref": {
      "groupId": "b2ee7923-e6c7-4ca3-86a0-6304559b935d",
      "artifactId": "rtf-training-demo",
      "version": "1.0.3",
      "packaging": "jar"
    },
    "configuration": {
      "mule.agent.application.properties.service": {
        "properties": {},
        "applicationName": "demoapp"
      }
    }
  },
  "desiredVersion": "bb4a44f8-9ee4-11ea-b729-771108e1cec4",
  "replicas": [
    {
      "state": "STARTED",
      "deploymentLocation": "274fbbcb-b56f-4b28-a209-8c21cae2e75b",
      "currentDeploymentVersion": "bb4a44f8-9ee4-11ea-b729-771108e1cec4",
      "reason": ""
    }
  ],
  "lastSuccessfulVersion": "bb4a44f8-9ee4-11ea-b729-771108e1cec4"
}'

(Send the request)
> curl -X PATCH 'https://anypoint.mulesoft.com/amc/application-manager/api/v2/\organizations/b2ee7923-e6c7-4ca3-86a0-xxxxxxxxx/environments/6c3c3e41-e5a1-4423-81bc-8c05778bd9cb/deployments/bbbe1236-6ef5-11ea-96c5-4fb8b4512917' \ 
--header 'Authorization: Bearer 97c4ac01-8be9-41f5-a239-xxxxx' \ 
--header 'Content-Type: application/json' --data-raw $PATCH_REQUEST
 

ADDITIONAL INFORMATION

Reference Scripts at set_jvm_args.sh. You will need to install jq

#!/bin/bash

set -xe

# Update with your own values
USERNAME="your_user_name"
PASSWORD="your_password"
ORG_ID="b2ee7923-e6c7-4ca3-86a0-6304559b935d"
ENV_ID="6c3c3e41-e5a1-4423-81bc-8c05778bd9cb"
APP_NAME="demoapp"
JVM_ARGS="-XX:NativeMemoryTracking=detail"


TOKEN=$(curl -sS -X POST https://anypoint.mulesoft.com/accounts/login -H 'Content-Type: application/json' \
  -d '{"username": "'$USERNAME'","password": "'$PASSWORD'"}' | jq -r '.access_token')


ID=$(curl -sS https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/$ORG_ID/environments/$ENV_ID/deployments \
  -H "Authorization: Bearer $TOKEN" | jq -r --arg APP_NAME "$APP_NAME" '.items | .[] | select(.name == $APP_NAME ) | .id ')

PATCH_REQUEST=$(curl -sS https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/$ORG_ID/environments/$ENV_ID/deployments/$ID \
  -H "Authorization: Bearer $TOKEN" | jq -r --arg JVM_ARGS "$JVM_ARGS" '.target.deploymentSettings.jvm.args = $JVM_ARGS')

curl -X PATCH https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/$ORG_ID/environments/$ENV_ID/deployments/$ID \
  -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' --data-raw "$PATCH_REQUEST"
Knowledge-artikelnummer

001116637

 
Laddar
Salesforce Help | Article