[rules-users] what is the difference between process variable & global variables?

Esteban Aliverti esteban.aliverti at gmail.com
Wed Apr 13 07:55:07 EDT 2011


These are some of the differences between variables and globals:

   - You can make inference about your globals using rules
   - Variables are persisted as part of the process instance info. Globals
   are not.
   - I didn't test it in every node type, but at least in Script Tasks, you
   can access process variables using just its name.

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Wed, Apr 13, 2011 at 8:39 AM, gs76pl <gstasica at pacemetrics.com> wrote:

> hi,
>
> this seems like a basic question i should know the answer to after reading
> some documentation but unfortunately after doing some tests with
> onExitActions there seems to be some discrepancy between what doc reads and
> how the process/action behaves. Could anyone verify my observations:
>
> 1. while documentation in "4.4. Data" reads "...Actions can access
> variables
> directly, simply by using the name of the variable as a parameter name" in
> fact this is INCORRECT as at that point actions expect a global object to
> be
> in the session!! e.g. below code in onExitAction throws an exception if
> tracker obj hasn't been defined as a global variable and entered into the
> session (it doesn't matter that the process has tracker variable defined)
>
> tracker.addVisitedNode("dasdf");
>
> 2. the only way of accessing process variables is via context object as
> below
>
> context.getVariable("tracker")
>
> 3. inserting/updating object in the session can be done
> a) context.getKnowledgeRuntime().insert("myFact");
> b) insert("myFact");
>
> looks like there is no difference here and the second one is simple a
> shorter version of doing the same
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/what-is-the-difference-between-process-variable-global-variables-tp2815658p2815658.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110413/1b47bc28/attachment.html 


More information about the rules-users mailing list