2 Replies Latest reply on May 28, 2012 1:53 AM by Richard Evans

    Sharing variables across jbpm processes

    Richard Evans Newbie

      Hello there.

      I want to define in one place a setting that is used as input to timer events in many processes. The value will change from environment to environment so I want to localise it.


      I guess that global variables should work...


      I defined the setting in the timer

      - Timer Delay: #{statusPollInterval}


      I then tried to set the global variable.

        - kSession.getGlobal.set("statusPollInterval", "2s") didn't seem to work

        - kRuntime.setGlobal.set("statusPollInterval", "2s") gave me an unexpected global message

      - The following spring config also give unexpected global.


      <drools:set-global identifier="statusPollInterval">

      <bean class="java.lang.String">

      <constructor-arg value ="2s"/>






      Q1. Is a global variable the best approach for shared settings like this?

      Q2. If so, what am I doing wrong? Do I have to declare the global in a drools:resource?


      I have searched previous discussions on globals but have not managed to get the answer. I am new to jbpm so would be grateful for anywone with the patience to assume little prior knowledge.

      My configuration is currently all in spring config.


      Many thanks,


        • 1. Re: Sharing variables across jbpm processes
          Mauricio Salatino Master

          Hi Richard? Where are you trying to do:

          kSession.getGlobal.set("statusPollInterval", "2s")

          kRuntime.setGlobal.set("statusPollInterval", "2s")


          That syntax is not even Java


          if you have access to the Knowledge Session you just do: ksession.setGlobal("statusPollInterval", "2s");


          If you don't have access, for example inside a process itself, you can use the kcontext object to access the knowledge runtime

          kcontext.getKnowledgeRuntime().setGlobal("statusPollInterval", "2s");


          That should work inside the processes and the rules.



          • 2. Re: Sharing variables across jbpm processes
            Richard Evans Newbie

            Thanks. Just a slip of the fingers. These are the two things I tried (written more carefully)


            kSession.getGlobal().set("statusPollInterval", "2s")

            kRuntime.setGlobal("statusPollInterval", "2s")


            The second "worked" in that it seems to have set a global variable. However when I executed the process I got an "Unexpected global [statusPollInterval]"


            Any ideas?