<br><font size=2 face="sans-serif">Kris,<br>
</font>
<br><font size=2 face="sans-serif">After posting my last question, I quickly
came to the same conclusion as you, so I'm now using a rule-based constraint
in my EventWait node.</font>
<br>
<br><font size=2 face="sans-serif">This however has presented a different
problem. If I create my session from JPAKnowledgeService, then when I try
to insert my fact into the session, I get the following error:</font>
<br>
<br><font size=2 face="sans-serif">bitronix.tm.internal.BitronixRollbackException:
transaction was marked as rollback only and has been rolled back</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; at
bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:153)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; at
bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.insert(CommandBasedStatefulKnowledgeSession.java:305)</font>
<p><font size=2 face="sans-serif">(Everything works fine if I create my
session from the knowledge base - i.e. with no state persistence.)</font>
<p><font size=2 face="sans-serif">Prior to using a rule-based constraint
(with no call to CommandBasedStatefulKnowledgeSession.insert), the session
created from JPAKnowledgeService worked OK.</font>
<p><font size=2 face="sans-serif">I'm using the default JPA configuration
from the Drools documentation (persisting to H2 database, etc.).</font>
<p><font size=2 face="sans-serif">Any ideas what might be causing the problem?</font>
<p><font size=2 face="sans-serif">Many thanks,</font>
<p><font size=2 face="sans-serif">Alan</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt;</b>
</font>
<p><font size=1 face="sans-serif">23/10/2009 03:00</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Rules Users List &lt;rules-users@lists.jboss.org&gt;,
Alan.Gairey@tessella.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">Rules Users List &lt;rules-users@lists.jboss.org&gt;</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [rules-users] [droolsflow] Code-based
constraints for EventWait nodes - is this possible?</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2>No, the constraint of an EventWait node (or the State
node in Drools<br>
5.1) can only be rule-based. &nbsp;The reason for this is that the rule<br>
engine knows when to re-evaluates rules (based on the evailable input).<br>
 If you would use a code-based constraint, the engine would have no idea<br>
when this code constraint might become true (if it was false at the<br>
start). &nbsp;Only constant re-evaluation of the code constraint could<br>
achieve this (which would be tremendously inefficient). &nbsp;Could you<br>
explain why you would like to have this behaviour? &nbsp;Maybe there is
an<br>
alternative way to model this.<br>
<br>
To change the value of a variable from inside the process (using an<br>
action), simply use kcontext.setVariable(name, value). &nbsp;We do not<br>
recommend manually changing the value of a process variable from outside<br>
the engine. &nbsp;Again, could you explain why you would like to have this<br>
functionality?<br>
<br>
Kris<br>
<br>
Quoting Alan.Gairey@tessella.com:<br>
<br>
&gt; Can the constraint for an EventWait node in a flow be code-based<br>
&gt; (rather <br>
&gt; than rule-based)? The Eclipse plug-in (v 5.0.1) doesn't allow this
to<br>
&gt; be <br>
&gt; specified, unlike say for a Split node, although the relevant XML
can<br>
&gt; of <br>
&gt; course be edited.<br>
&gt; Trying to load such a process flow results in a NullPointerException,<br>
&gt; <br>
&gt; because the constraint is always interpreted as a rule.<br>
&gt; <br>
&gt; Ideally what I'd like to do is have an EventWait node where the<br>
&gt; constraint <br>
&gt; tests the value of a process variable. This then leads me to another<br>
&gt; <br>
&gt; question; is there a way of setting the value of a process variable<br>
&gt; via <br>
&gt; the Drools Flow API?<br>
&gt; <br>
&gt; Thanks in advance for any help,<br>
&gt; <br>
&gt; Alan<br>
&gt; Tessella plc<br>
&gt; 26 The Quadrant, Abingdon Science Park, Abingdon, Oxfordshire, OX14<br>
&gt; 3YS<br>
&gt; E: Alan.Gairey@tessella.com, T: +44 (0)1235 555511, F: +44 (0)1235<br>
&gt; 553301<br>
&gt; www.tessella.com &nbsp; &nbsp;Registered in England No. 1466429<br>
&gt; <br>
&gt; This message is commercial in confidence and may be privileged. It
is<br>
&gt; <br>
&gt; intended for the addressee(s) only. Access to this message by anyone<br>
&gt; else <br>
&gt; is unauthorized and strictly prohibited. If you have received this<br>
&gt; message <br>
&gt; in error, please inform the sender immediately. Please note that<br>
&gt; messages <br>
&gt; sent or received by the Tessella e-mail system may be monitored and<br>
&gt; stored <br>
&gt; in an information retrieval system.<br>
&gt; <br>
<br>
<br>
<br>
<br>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
</font></tt>
<br>