1

as from my previous question i had to use environment variable to set interval for trigger in task , now i need to do same but instead of environment variable i need set same variable with same value in deployment.toml or elsewhere in my MI

i want set variable (i think it will be in deployment.toml) and use it as interval for my task trigger , so i will not need extra script to set environment variable on server where MI runs

1 Answers1

1

You can't directly read variables from the deployment.toml OOB. But here is how you can do the same with a properties file.

  1. Create a file named file.propertiesin MI_HOME/conf directory and add the following content
TASK_FREQUENCY=* * * * *
  1. Now in your task you should be able to read this property like below.
<trigger cron="$FILE:TASK_FREQUENCY"/>
<?xml version="1.0" encoding="UTF-8"?>
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="TestTask" xmlns="http://ws.apache.org/ns/synapse">
    <trigger cron="$FILE:TASK_FREQUENCY"/>
    <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="injectTo" value="sequence"/>
    <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
             <m0:getQuote xmlns:m0="http://services.samples">
                <m0:request>
                   <m0:symbol>IBM</m0:symbol>
                </m0:request>
             </m0:getQuote>
          </property>
    <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="sequenceName" value="SeqMy"/>
</task>

Documentation here.

ycr
  • 12,828
  • 2
  • 25
  • 45