...
Question: How can I trigger a job or a jobchain job chain based on a (series of) event(s)?
...
In some cases it is necessary to trigger a job (or a jobchainjob chain) based on (multiple) events (other jobs, monitored files...) which might even occur on different hosts.
...
- start a single job which will do something,
- watch a folder for an incoming file with the extension ".txt" and start at job to process and/or move this file
- watch the same folder for an incoming file with the extension ".pdf" and start a jobchain job chain to process and move this file
after these three actions are executed, in a randomly sequence, and successfully finished, another jobchain job chain must be started and all events must be cleared.
...
- Put a .pdf file in the
files/in
directory.
This will causesamples/events/file_job
to run and move the file to thefiles/processed
directory. (3rd event)
When all three events (comming coming from simple_shell_job, .txt file, .pdf file) were thrown, the job samples/events/done_job
will immediately start and executes the requested action: delete the files from the files/processed
directory.
...
to signal an event of call "example" to the active instance of the eventservice JobScheduler.
The -x
switch sets the exit code of the previous shell-command (echo
in this case), and the -e
switch sets the event class as properties of the event.
Other properties (which do not need to be set as parameters for the script jobscheduler_event.sh) include the name of the job which created the event, the name of the jobchain job chain (if the job was called in a chain), name of the order ...
...
No Format |
---|
*[_job_name_].*.job.xsl will be run for events created by the job [_job_name_] *[_job_chain_name_].*.job_chain.xsl will be run for events created by a job in the jobchainjob chain [_job_chain_name_] *[_event_class_name_].*.event_class.xsl will be run for events with the event class [_event_class_name_] |
...
The event handler (stylesheet) has a template which tries to find 3 events, one from the simple_shell_job
job, and one from each of the file handling jobchainsjob chains:
Code Block |
---|
<xsl:template match="events[ event[@job_name='simple_shell_job'] and event[@job_chain='txt_chain'] and event[@job_chain='pdf_chain'] ]"> |
...
The second command cleans up the current set of events of the event class example
to avoid triggering samples/events/done_job
again before all 3 events have occuredoccurred:
Code Block |
---|
<remove_event> <event event_class="example"/> </remove_event> |
...