Annotated Example One
This example includes instructions on how to:
- create a “HelloWorld” script using the Developer IDE.
- create the Event Domain and associate your script
with it.
- send an event to the xMatters Node using Java
Client to test the event domain.
- review the resulting event (contained in a log
file).
To create the “HelloWorld” script:
- Click Start >
Programs > xMatters systems > xMatters Developer IDE
to launch the xMatters Developer IDE.
- In the Workspace pane on the left side of the
screen, right-click the Workspace
item, and then select New Script Package.
- In the Name
field of the New Script Package dialog box, type HelloWorld.
- In the Type
drop-down list, select Business,
and type a brief description in the Description
field.
- Click OK.
- In the Workspace pane, right-click HelloWorld,
and then select New Package Version.
- In the Script Version Properties dialog box, in
the Label field, type 1.0.
- In the Status drop-down list, select Production,
and then click OK.
- In the Workspace pane, right-click PROCESS,
and then select New Script.
- In the Script Properties dialog box, in the Name field, type initial,
and then type a description for the script in the Notes
field.
- The entry point for all business scripts is
under the PROCESS category. Only
one script is permitted under this category.
- In the Workspace pane, double-click the initial script.
- When a script is first created, it is empty. Each
script file must contain a “main:” tag to indicate that this is the starting
point in the script file. Additionally, the sample code contains comments
that start with the “#” symbol and continue to the end of the line. For
this example, the “script” object is used to set up a log file, and then
write the string “Hello World!” to that log file. The
logfile is called “HelloWorld.log” and resides in the xMatters installation
under a subdirectory called “logs”.
- Type (or copy and paste) the following code into
the initial script window to create the script:
##################################################################
#
# Script: HelloWorld/PROCESS/initial
#
# This is the main entry point for this script package.
#
##################################################################
#/////////////////////////////////////////////////////////////////
# This is the main entry point for this script. Whenever
a
# message is sent to the domain that owns this script package,
# this script is called.
#/////////////////////////////////////////////////////////////////
main:
#
write the log entry to the file
@script::log("Hello
World!")
### DONE: main ###
- Click the Save
All Unsaved Scripts button in the toolbar to save the changes.
- Click Validate
Selected Workspace Item.
- The xMatters Developer IDE validates the
script (this must be done before you can check this script into the database).
If the script is valid, the Complete message is displayed.
- Click Check In
Selected Workspace Item to save the script package to the database.
- When prompted whether to create the script package
in the database, click Create.
Next topic:
Configuring the Event Domain