We can define initial state functions for our beloved KX processes on KX Control, but what about stop state functions? Say I want an RTE to do a few things on close, how could I do that?
EDIT: See @rocuinneagain 's reply for the optimal solution for this question.
You would need to define an analytic (or analyticgroup) that is loaded by your RTE process, then send a message to that process via IPC (for example) just prior to shutting down your, if there is some specific steps you want to take prior to shutdown.
Alternatively, you could also add a wrapper around your eodFunct to carry out your steps if you RTE stops just after EOD, or you could also try using the timer functions on the process say e.g. once per day to achieve something similar.
Hope this helps,
Thanks for the reply. It looks like what I already do is in line with what you told me.
Here is my scenario:
I have one workflow that contains a single RTE that I use to start a bunch of service classes.
To do that, i used the initial state function of the RTE to call the startServiceCSV.sh script provided on the KX Data Warehouse tutorial. Meanwhile, the csv contains hardcoded information about the "parent" RTE at each service class row.
Then, each service class has a custom initStateFunction that, among other things, creates an IPC handle to their parent RTE and keeps checking (with a timer) if the handle is still valid. So whenever i stop the workflow, the RTE obviously dies, making the handles invalid and therefore killing the services.
I asked about a stopStateFunction because if such a thing existed, i would not have to do the ipc logic 😆 - but what I am getting from your response is that this is as good as it gets?
Update: I did more investigation and found out .z.exit and that solved my problem.
Inside the initialStateFunction of the RTE, I assigned .z.exit to a function that calls the stopServiceCSV.sh script, thus eliminating the need of using timers 😄
Tel: +44 (0)28 3025 2242
Tel: +1 (212) 447 6700
Tel: +61 (0)2 9236 5700