KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums KX Solutions KX Control – stopStateFunct?

  • KX Control – stopStateFunct?

    Posted by Laura on August 9, 2021 at 12:00 am

    Hi all,

    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?

    Kind regards,

    Laura replied 2 months ago 3 Members · 4 Replies
  • 4 Replies
  • dcrossey

    August 9, 2021 at 12:00 am

    EDIT: See @rocuinneagain ‘s reply for the optimal solution for this question.

    Hi adrainosm_,

    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,


  • rocuinneagain

    August 10, 2021 at 12:00 am

    On the KX Platform you should not use .z.exit directly as it performs some inbuilt operations.

    Instead use .ch.addExit which is a handler for you to add your custom behaviour on top of what is inbuilt.



  • Laura

    August 10, 2021 at 12:00 am

    Hi David,
    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?



  • Laura

    August 10, 2021 at 12:00 am

    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

Log in to reply.