Based on you example, you might want to consider defining a global and passing similarly the to what you show, and in your code where you initialize the KnowledgeSession, set the global from your Java code. In this way, you can uniquely identify each session using a uid that you define in your own code.
Like this: Import java.util.UUID global UUID uid rule 'something' when ...... then Notification.sendSMS(uid); End In JAVA: private UUID firerulesForSession(StatefulKnowledgeSession kSession) { final String sourceMethod = "firerulesForSession"; // generate a globally unique ID. Preferably this should be passed in as an argument. final UUID uid = UUID.randomUUID(); kSession.setGlobal("uid",uid); ... log.fine("Preparing Command Factory"); List<Command<?>> cmds = new ArrayList<Command<?>>(); cmds.add(CommandFactory.newInsertElements(facts)); cmds.add(CommandFactory.newFireAllRules()); // start a new process instance try { log.info("Firing Rules: "); // kSession.execute(getFacts(bbSecurity, packageName)); kSession.execute(CommandFactory.newBatchExecution(cmds)); } catch (Throwable e) { log.throwing(sourceClass, sourceMethod, e); } return uuid; } Of course you will need to adapt for your solution, and a GUID (UUID) may be overkill for what you're doing, and since the kSession.execute() is not an asynchronous call, you need to deal with the uuid before firing the rules, so that the sendSMS() function will know what the UUID means. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Bobby Richards Sent: Wednesday, April 18, 2012 6:18 PM To: rules-users@lists.jboss.org Subject: [rules-users] global identifier Is there a way to create a 'global' that is completely specific to a drl file rather than the working memory? I only wish to use this in rhs notification/persistence operations, ie passing a user's unique id to a db or sms operation. I know this does not work but perhaps it will help to better illustrate my question: global int user_id = 123; ... then notification.sendSMS(user_id);
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users