No announcement yet.

Executing code only once

  • Filter
  • Time
  • Show
Clear All
new posts

  • Executing code only once


    I have a channel that gets HL7-ORU-Mesages. On every message it makes a lookup (using SELECT...) in the database to check if a value is in the db or not.

    The problem is that this SELECT executes on every message that my channel gets, which causes DB-Performance-Problem. Is there a way to execute the SELECT only once (for example with the first message) and then keep the result, so that for the next messages the channel doesn't need to execute it?

    Thank you,


  • #2
    Re:Executing code only once

    I don't have specifics because I've never done it before, but I think that is what a deploy script is for.
    Jon Bartels

    Zen is hiring!!!!
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.


    • #3
      Re:Executing code only once

      If you are in need of querying the DB based on message content, I believe that you won't be able to do that within the deploy script. How about using the Deploy script as jbartels mentioned to initialize a global variable to indicate a DBselect has not been done and place that on the map. In your transformer javascript extract the variable from the map, check the value an if a DBselect has not been performed execute one and set the variable to a value to indicate the dbselect was done? The problem I see with this approach is when the channel is stopped and started , I don't know how to detect that the channel has stopped within the transformer, if there is a way to do that then the variable initialized at deployment can be re-intitialized when the channel stops for whatever reason (Normal, Error etc)

      Post edited by: rts, at: 10/07/2008 06:31


      • #4
        Re:Executing code only once

        Thank you guys!

        It worked with the preprocessor. I read the needed values there and saved them on an array. I mapped this array as global variable.

        It's pretty cool - the array initializes only once and then it keeps existing no matter how many messages come.