1.7 Scripts - jmstoolbox/jmstoolbox GitHub Wiki

Scripts

A major feature of JMSToolBox is the possibility to create scripts. A scripts in JMSToolBox is composed of a list of steps, a collection of global variables and optionally a collection of data files or payload directories. There are two kinds of steps:

  • regular: defines the action of posting a template message to a specific destination
  • pause: will pause the script for a certain amount of seconds

Steps

A step is composed of:

  • a template
  • a session
  • a destination
  • optionally a data file (CSV format) or a directory where to read payloads (Mutually exclusive)
  • a number of second for the script to pause after a message is post If a data file is associated with a script, for each template of the directory, a message will be generated for each row of the data file. If the step is associated with a directory of payloads, at runtime, the template body will be repeatedly replaced by the content of every file contained in that directory and then posted in the destination,

Global Variables

As explained in the [Templates and Variables] page, templates can embed various variables that are resolved before posting the template to a destination. The value for the variable will be generated once for the whole template, even if a variable appears multiple times inside a single template. In a script, it is possible to mark some variables as global. In this case, the generated value will be the same for all the templates in the steps in the script For example, an "INT" variable could be defined to generate an "order number". If this variable is marked as global in the script, JMSToolBox will generate a value once and only once and use it across all the templates in the script It is also possible to "force" a value for a variable (instead of letting JMSToolBox generate a random one), the constant will then be used for all the templates in the script

Data Files

The execution of the step execution may be driven by data stored in a data file. Data files are "comma delimited" files (csv) that can be attached to a step. In this case, the step will be repeatedly executed for each line found in the data file. A data file is described by:

  • A prefix variable that will be used in template to references the variables defined in the data file, eg "df1"
  • A list of variables separated by commas, eg "col1,col2,col3"
  • A delimiter string to separate data in the data file
  • the encoding charset of the file (UTF-8, Cp1252...)
  • The name of the file Variables from the data file are referenced by using ${.<var name} in the template attached to the step, For example, if the prefix variable is "df1" and the list of variables is "col1,col2", the following variables can be used in the associated template:
  • ${df1.col1}
  • ${df1.col2}

Directory of payload files (v4.1.0)

If the step is associated with a directory of payloads, at runtime, the template body will be repeatedly replaced by the content of every file contained in that directory and then posted in the destination.

Script Execution, Script Simulation

To "execute" a script, either use the corresponding contextual menu of the toolbar. The result will appear in the "Execution Log" view. The generated messages can be edit/saved from the execution logs It is also possible to "simulate" the execution of a script. The difference between "execution" and "simulation" is that the generated messages will not be post to the Q, and the pause will not be executed. This mode allows to validate that the generated messages are as expected, regarding the global or local variables. Executing and simulating a script both start by validating the the variable, templates, sessions and destination still exist and that the script can connect to the sessions declared in the script.

⚠️ **GitHub.com Fallback** ⚠️