Esta página no está disponible actualmente en Español. Si lo necesita, póngase en contacto con el servicio de asistencia de Icon (correo electrónico)

RD 3 - Use Dynamic Variables

Dynamic Variables

Dynamic variables are values used within the Rules Framework that can be updated via configuration or at runtime.

For a more indepth look at dynamic expressions, see the documentation here: Dynamic Expressions

Objective

In the previous step we added a decision based on the value of the payment. Now we want to allow the threshold value to be configurable at runtime, and we will use Dynamic Variables to achieve this.

DSL Set Up

To see a completed example of this step, open the dynamic-variable-solution module.

Creating Dynamic Variables

To start, let’s create a library for the dynamic variables. Right-click on the model, then select New  c.iconsolutions.simple  DynamicVariableLibrary

create dynamic variable node

Give the library a name, then add a new entry for our variable. A variable’s type can either be number, string, boolean or a list of the those. We want to make the threshold for what constitutes a high-value payment a configurable value, so create a variable named amountThreshold, give it type number and a default value of 1000.

dynamic variable node

Adding Dynamic Variables to Decisions

Go back to the decision node from earlier. Under imports add the newly created Dynamic Variable Library. We can now replace the constant threshold from earlier with a reference to our variable.

dynamic variable use

Testing

For each Dynamic variable library created we will need to add it as a bean such as the example below. This configuration class can also be found in the dynamic-variable-solution solution.

package rulestutorialsolution.app.controller;

import com.iconsolutions.kfextensions.runtime.DynamicVariableLibrary;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import rulestutorialmodel.PaymentVariableLibrary;

@Configuration
public class DynamicVariablesConfiguration {

    @Bean
    public DynamicVariableLibrary dynamicVariableLibrary(){
        return PaymentVariableLibrary.INSTANCE;
    }
}

Dynamic variables can be overwritten in a few ways. For this example we will cover overwriting the variables via Hocon configuration and using a custom endpoint.

Updating via Configuration

Within ipf-impl.conf add the following configuration

ipf.studio = {
  models = [{
    name = "rulestutorialmodel"
    configurable-values-global ={
      amountThreshold = 5000
    }
    entities =[]
    }
  ]
}

The name must be the name of the model, and the fields should match the variable names.

This will overwrite the variable on a global scope

The application should be ready to run now after another build via:

mvn clean install

Start up the application and try sending the these payments to see the threshold has been changed from 1000 to 5000

Low Value Message
curl -d '{"requestId":"HoconLowValueRequest","pacs008":{"grpHdr": {"msgId": "ExampleMessageId", "creDtTm": "2025-10-27T17:27:29.886889529Z", "nbOfTxs": "1", "intrBkSttlmDt": "2025-10-27", "sttlmInf": {"sttlmMtd": "CLRG", "clrSys": {"prtry": "EBA"}}}, "cdtTrfTxInf": [{"pmtId": {"endToEndId": "VIVNxmihFItoyyjAPLTqnwqOpoaWUgFHcFr", "txId": "TugAtCCIQtcUYcFfGVGAHFNfdUjeCokipAn"}, "intrBkSttlmAmt": {"value": 4000, "ccy": "EUR"}, "accptncDtTm": "2025-10-27T17:27:29.878336788Z", "chrgBr": "SLEV", "dbtr": {"nm": "James Allen", "pstlAdr": {"adrLine": ["213 South Street"]}, "id": {"orgId": {"anyBIC": "PRXYITMM"}}}, "dbtrAcct": {"id": {"iban": "GB38UVCRXEHFCFLMQNBTWFSWXISKIW"}, "ccy": "EUR", "nm": "Chloe Williams"}, "dbtrAgt": {"finInstnId": {"bicfi": "ICONGBA1", "clrSysMmbId": {"mmbId": "191919"}, "pstlAdr": {"adrLine": ["897 North Street"]}}}, "cdtrAgt": {"finInstnId": {"bicfi": "ICONGBA0", "clrSysMmbId": {"mmbId": "400302"}, "nm": "Chloe Hughes", "pstlAdr": {"adrLine": ["465 Main Street"]}}, "brnchId": {"id": "iWULDmNwqrZLcrNNmxlELmWDrQGgGdeOavf"}}, "cdtr": {"nm": "Sophia Phillips", "pstlAdr": {"adrLine": ["293 Kingsway"]}, "id": {"orgId": {"lei": "12345678901234567888", "anyBIC": "KJFISESS"}}}, "cdtrAcct": {"id": {"iban": "CZ6508000000192000145399"}}}]}}' -H 'Content-Type: application/json'  http://localhost:8080/submit
High Value Message
curl -d '{"requestId":"HoconHighValueRequest","pacs008":{"grpHdr": {"msgId": "ExampleMessageId", "creDtTm": "2025-10-27T17:27:29.886889529Z", "nbOfTxs": "1", "intrBkSttlmDt": "2025-10-27", "sttlmInf": {"sttlmMtd": "CLRG", "clrSys": {"prtry": "EBA"}}}, "cdtTrfTxInf": [{"pmtId": {"endToEndId": "VIVNxmihFItoyyjAPLTqnwqOpoaWUgFHcFr", "txId": "TugAtCCIQtcUYcFfGVGAHFNfdUjeCokipAn"}, "intrBkSttlmAmt": {"value": 6000, "ccy": "EUR"}, "accptncDtTm": "2025-10-27T17:27:29.878336788Z", "chrgBr": "SLEV", "dbtr": {"nm": "James Allen", "pstlAdr": {"adrLine": ["213 South Street"]}, "id": {"orgId": {"anyBIC": "PRXYITMM"}}}, "dbtrAcct": {"id": {"iban": "GB38UVCRXEHFCFLMQNBTWFSWXISKIW"}, "ccy": "EUR", "nm": "Chloe Williams"}, "dbtrAgt": {"finInstnId": {"bicfi": "ICONGBA1", "clrSysMmbId": {"mmbId": "191919"}, "pstlAdr": {"adrLine": ["897 North Street"]}}}, "cdtrAgt": {"finInstnId": {"bicfi": "ICONGBA0", "clrSysMmbId": {"mmbId": "400302"}, "nm": "Chloe Hughes", "pstlAdr": {"adrLine": ["465 Main Street"]}}, "brnchId": {"id": "iWULDmNwqrZLcrNNmxlELmWDrQGgGdeOavf"}}, "cdtr": {"nm": "Sophia Phillips", "pstlAdr": {"adrLine": ["293 Kingsway"]}, "id": {"orgId": {"lei": "12345678901234567888", "anyBIC": "KJFISESS"}}}, "cdtrAcct": {"id": {"iban": "CZ6508000000192000145399"}}}]}}' -H 'Content-Type: application/json'  http://localhost:8080/submit

Updating via Custom Endpoint

Another possible approach to updating dynamic variables is using the DynamicExpressionRegistry API. If you look within the rules-tutorial-utils module you will find some extra classes that define a custom endpoint /dynamic-variables that can update the dynamic variables at runtime.

Run the application again and send this message to update the threshold to 10,000 this time.

The key for the variable is of the form <modelName>_<variableName>

Update Threshold
curl -d '{"key":"rulestutorialmodel_amountThreshold","value":10000}' -H 'Content-Type: application/json'  http://localhost:8080/dynamic-variable

Now to see the variable has been updated, we can send in new requests with different values.

New Low Value Message
curl -d '{"requestId":"RuntimeLowValueRequest","pacs008":{"grpHdr": {"msgId": "ExampleMessageId", "creDtTm": "2025-10-27T17:27:29.886889529Z", "nbOfTxs": "1", "intrBkSttlmDt": "2025-10-27", "sttlmInf": {"sttlmMtd": "CLRG", "clrSys": {"prtry": "EBA"}}}, "cdtTrfTxInf": [{"pmtId": {"endToEndId": "VIVNxmihFItoyyjAPLTqnwqOpoaWUgFHcFr", "txId": "TugAtCCIQtcUYcFfGVGAHFNfdUjeCokipAn"}, "intrBkSttlmAmt": {"value": 6000, "ccy": "EUR"}, "accptncDtTm": "2025-10-27T17:27:29.878336788Z", "chrgBr": "SLEV", "dbtr": {"nm": "James Allen", "pstlAdr": {"adrLine": ["213 South Street"]}, "id": {"orgId": {"anyBIC": "PRXYITMM"}}}, "dbtrAcct": {"id": {"iban": "GB38UVCRXEHFCFLMQNBTWFSWXISKIW"}, "ccy": "EUR", "nm": "Chloe Williams"}, "dbtrAgt": {"finInstnId": {"bicfi": "ICONGBA1", "clrSysMmbId": {"mmbId": "191919"}, "pstlAdr": {"adrLine": ["897 North Street"]}}}, "cdtrAgt": {"finInstnId": {"bicfi": "ICONGBA0", "clrSysMmbId": {"mmbId": "400302"}, "nm": "Chloe Hughes", "pstlAdr": {"adrLine": ["465 Main Street"]}}, "brnchId": {"id": "iWULDmNwqrZLcrNNmxlELmWDrQGgGdeOavf"}}, "cdtr": {"nm": "Sophia Phillips", "pstlAdr": {"adrLine": ["293 Kingsway"]}, "id": {"orgId": {"lei": "12345678901234567888", "anyBIC": "KJFISESS"}}}, "cdtrAcct": {"id": {"iban": "CZ6508000000192000145399"}}}]}}' -H 'Content-Type: application/json'  http://localhost:8080/submit
New High Value Message
curl -d '{"requestId":"RuntimeHighValueRequest","pacs008":{"grpHdr": {"msgId": "ExampleMessageId", "creDtTm": "2025-10-27T17:27:29.886889529Z", "nbOfTxs": "1", "intrBkSttlmDt": "2025-10-27", "sttlmInf": {"sttlmMtd": "CLRG", "clrSys": {"prtry": "EBA"}}}, "cdtTrfTxInf": [{"pmtId": {"endToEndId": "VIVNxmihFItoyyjAPLTqnwqOpoaWUgFHcFr", "txId": "TugAtCCIQtcUYcFfGVGAHFNfdUjeCokipAn"}, "intrBkSttlmAmt": {"value": 11000, "ccy": "EUR"}, "accptncDtTm": "2025-10-27T17:27:29.878336788Z", "chrgBr": "SLEV", "dbtr": {"nm": "James Allen", "pstlAdr": {"adrLine": ["213 South Street"]}, "id": {"orgId": {"anyBIC": "PRXYITMM"}}}, "dbtrAcct": {"id": {"iban": "GB38UVCRXEHFCFLMQNBTWFSWXISKIW"}, "ccy": "EUR", "nm": "Chloe Williams"}, "dbtrAgt": {"finInstnId": {"bicfi": "ICONGBA1", "clrSysMmbId": {"mmbId": "191919"}, "pstlAdr": {"adrLine": ["897 North Street"]}}}, "cdtrAgt": {"finInstnId": {"bicfi": "ICONGBA0", "clrSysMmbId": {"mmbId": "400302"}, "nm": "Chloe Hughes", "pstlAdr": {"adrLine": ["465 Main Street"]}}, "brnchId": {"id": "iWULDmNwqrZLcrNNmxlELmWDrQGgGdeOavf"}}, "cdtr": {"nm": "Sophia Phillips", "pstlAdr": {"adrLine": ["293 Kingsway"]}, "id": {"orgId": {"lei": "12345678901234567888", "anyBIC": "KJFISESS"}}}, "cdtrAcct": {"id": {"iban": "CZ6508000000192000145399"}}}]}}' -H 'Content-Type: application/json'  http://localhost:8080/submit