<br><font size=2 face="sans-serif">Thanks for the quick response.</font>
<br>
<br><font size=2 face="sans-serif">Unfortunately I have an arbitrary number
of sub flows, so I don't think I can use a Split and Join. Using the term
"sub flow" might be a bit misleading; what I really have is a
work item that can launch an arbitrary number of independent processes,
each with their own stateful knowledge session. I need each of them to
insert a fact into the working memory of the original session, and for
the wait state in the original session to then be processed correctly.</font>
<br>
<br><font size=2 face="sans-serif">I hope the example project I posted
is understandable - please let me know if I can supply any further information.<br>
</font>
<br><font size=2 face="sans-serif">Regards,</font>
<br>
<br><font size=2 face="sans-serif">Alan</font>
<p><font size=2 face="Arial"><b>Tessella plc</b><br>
26 The Quadrant, Abingdon Science Park, Abingdon, Oxfordshire, OX14 3YS<br>
E: Alan.Gairey@tessella.com, T: +44 (0)1235 555511, F: +44 (0)1235 553301<br>
www.tessella.com Registered in England No. 1466429</font>
<p><img src=cid:_1_11DF8CCC11DF8AA4004EA20980257711>
<p><font size=1 face="Arial">This message is commercial in confidence and
may be privileged. It is intended for the addressee(s) only. Access to
this message by anyone else is unauthorized and strictly prohibited. If
you have received this message in error, please inform the sender immediately.
Please note that messages sent or received by the Tessella e-mail system
may be monitored and stored in an information retrieval system.</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>rudolf michael <roudolf@gmail.com></b>
</font>
<br><font size=1 face="sans-serif">Sent by: rules-users-bounces@lists.jboss.org</font>
<p><font size=1 face="sans-serif">26/04/2010 15:05</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Rules Users List <rules-users@lists.jboss.org></font></div></table>
<br>
<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 <rules-users@lists.jboss.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<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] Multithreading work
items</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>Alan, couldn't you have achieved this using
a Split and Join?<br>
</font>
<br><font size=3>2010/4/26 <</font><a href=mailto:Alan.Gairey@tessella.com><font size=3 color=blue><u>Alan.Gairey@tessella.com</u></font></a><font size=3>></font>
<br><font size=2 face="sans-serif"><br>
Interesting. What you've described Pedro is similar to what I'm trying
to achieve, and also relates to some earlier posts I made to the list (title:
'Drools Flow: Problem with constraint in (Wait) State node').</font><font size=3><br>
</font><font size=2 face="sans-serif"><br>
I have a process that launches independent sub flows; these independent
sub flows execute on separate threads. I then want the original process
to "block" until all the subflows have finished, and to then
continue.</font><font size=3> </font><font size=2 face="sans-serif"><br>
In order to achieve this, I've done the following:</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
- Each process (both the main flow and each sub flow) is executed by a
separate stateful knowledge session.</font><font size=3> </font><font size=2 face="sans-serif"><br>
- When a sub flow is started, it inserts a fact into the working memory
of the session for the original process.</font><font size=3> </font><font size=2 face="sans-serif"><br>
- When a sub flow finishes, it updates a fact in the working memory of
the session for the original process to "signal" its completion.</font><font size=3>
</font><font size=2 face="sans-serif"><br>
- After launching the sub flows, the original process contains a (wait)
state node; the constraint for this node is designed to block until all
facts in its memory are in the "signalled" state.</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
I've attached an example project that illustrates what I'm trying to achieve.
The constraint on the wait state node is currently as follows:</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
(and forall(SimpleFact(complete == true)) exists(SimpleFact()))</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
I'd be interested to know from someone who understands rule syntax better
than me as to why this seems to work when other attempts (see my earlier
posts) failed.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
I still have two problems though:</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
1) The above constraint appeared to work OK with an earlier 5.1 snapshot
build (from a couple of months back). However, using the latest successful
build from trunk (#3845), the Action node after the wait state node isn't
executed. Given that 5.1.M2 is supposed to be imminent, I'm worried. Does
anyone know why this no longer works?</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
2) If I try to enable JPA-based state persistence, using the Bitronix transaction
manager, then when I try to insert a fact into the working memory
of the session for the original process from a separate thread, I get the
following error:</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
bitronix.tm.internal.BitronixRollbackException: transaction was marked
as rollback only and has been rolled back</font><font size=3> </font><font size=2 face="sans-serif"><br>
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:153)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.insert(CommandBasedStatefulKnowledgeSession.java:306)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at com.test.InsertWorkItemHandler$1.insertFact(InsertWorkItemHandler.java:52)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at com.test.InsertWorkItemHandler$1.run(InsertWorkItemHandler.java:40)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at java.lang.Thread.run(Thread.java:619)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
java.lang.RuntimeException: Could not rollback transaction</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:283)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.insert(CommandBasedStatefulKnowledgeSession.java:306)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at com.test.InsertWorkItemHandler$1.insertFact(InsertWorkItemHandler.java:52)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at com.test.InsertWorkItemHandler$1.run(InsertWorkItemHandler.java:40)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at java.lang.Thread.run(Thread.java:619)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
Caused by: java.lang.IllegalStateException: no transaction started on this
thread</font><font size=3> </font><font size=2 face="sans-serif"><br>
at bitronix.tm.BitronixTransactionManager.rollback(BitronixTransactionManager.java:103)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:278)</font><font size=3>
</font><font size=2 face="sans-serif"><br>
... 4 more</font><font size=3> </font>
<p><font size=2 face="sans-serif">Any help anyone can provide would be
very much appreciated. Thank you.</font><font size=3> </font>
<p><font size=2 face="sans-serif">Regards,</font><font size=3> </font>
<p><font size=2 face="sans-serif">Alan</font><font size=3> </font>
<p><font size=3><br>
<br>
</font>
<p>
<table width=100%>
<tr valign=top>
<td width=53%><font size=1 face="sans-serif"><b>Pedro Maria Buitrago Mantilla
<</b></font><a href=mailto:pmbtgun@gmail.com target=_blank><font size=1 color=blue face="sans-serif"><b><u>pmbtgun@gmail.com</u></b></font></a><font size=1 face="sans-serif"><b>></b>
</font>
<br><font size=1 face="sans-serif">Sent by: </font><a href="mailto:rules-users-bounces@lists.jboss.org" target=_blank><font size=1 color=blue face="sans-serif"><u>rules-users-bounces@lists.jboss.org</u></font></a><font size=3>
</font>
<p><font size=1 face="sans-serif">23/04/2010 14:38</font><font size=3>
</font>
<p>
<br>
<table border=4>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Rules Users List <</font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=1 color=blue face="sans-serif"><u>rules-users@lists.jboss.org</u></font></a><font size=1 face="sans-serif">></font></div></table>
<br>
<td width=46%>
<table width=100%>
<tr valign=top>
<td width=14%>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td width=85%><font size=1 face="sans-serif">Rules Users List <</font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=1 color=blue face="sans-serif"><u>rules-users@lists.jboss.org</u></font></a><font size=1 face="sans-serif">></font><font size=3>
</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<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] Multithreading work
items</font></table>
<br>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br><font size=3><br>
<br>
<br>
Each of the sub flows requires final user design. Mauricio thanks very
much. <br>
<br>
PEDRO BUITRAGO<br>
Bogotá, Colombia<br>
<br>
<br>
2010/4/22 Mauricio Salatino <</font><a href=mailto:salaboy@gmail.com target=_blank><font size=3 color=blue><u>salaboy@gmail.com</u></font></a><font size=3>>
<br>
yes.. sounds more like a normal java problem than Drools FLow problem.
I think that your solution is the correct one because it handle internally
the multithreaded requierements and then it continue the business process
normally.<br>
<br>
<br>
2010/4/22 Pedro Maria Buitrago Mantilla <</font><a href=mailto:pmbtgun@gmail.com target=_blank><font size=3 color=blue><u>pmbtgun@gmail.com</u></font></a><font size=3>>
<br>
<br>
The idea is to run multiple independent sub flows. Each of the sub flows
requires approximately 2 minutes to complete, so parallel processing is
required. Once all the sub flows have completed their tasks is necessary
to collect all the results and process them. This implies that the workflow
should not end until it collects all information submitted by the sub flows.<br>
<br>
For now, I think to create, with JMS, a queue in jboss receive the name
of each sub flow, create your own KnowledgeBase run each subflow as a separate
workflow and delivers the results. Finally, some components will take all
the results (from a database of another jms queue and process and again
another component start another workflow to process all results.<br>
<br>
<br>
PEDRO BUITRAGO<br>
Bogotá, Colombia<br>
<br>
<br>
2010/4/22 Mauricio Salatino <</font><a href=mailto:salaboy@gmail.com target=_blank><font size=3 color=blue><u>salaboy@gmail.com</u></font></a><font size=3>>
<br>
<br>
can you describe a little bit your use case?<br>
I'm not sure about what you want to achieve.<br>
<br>
2010/4/21 Pedro Maria Buitrago Mantilla <</font><a href=mailto:pmbtgun@gmail.com target=_blank><font size=3 color=blue><u>pmbtgun@gmail.com</u></font></a><font size=3>>
<br>
In general, I meet that for resolve the topic of multithreading it's required
to implement another thread over a work item.<br>
<br>
How does the asynchronic task can modified a variable of Knowledgebase?<br>
<br>
Can you give me an example?</font><font size=3 color=#8f8f8f><br>
<br>
Pedro Buitrago<br>
</font><font size=3><br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=3 color=blue><u>rules-users@lists.jboss.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><font size=3 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a><font size=3><br>
<br>
<br>
<br>
<br>
-- <br>
- </font><a href=http://salaboy.wordpress.com/ target=_blank><font size=3 color=blue><u>http://salaboy.wordpress.com</u></font></a><font size=3><br>
- </font><a href=http://www.jbug.com.ar/ target=_blank><font size=3 color=blue><u>http://www.jbug.com.ar</u></font></a><font size=3><br>
- Salatino "Salaboy" Mauricio - <br>
<br>
_______________________________________________<br>
rules-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=3 color=blue><u>rules-users@lists.jboss.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><font size=3 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a><font size=3><br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=3 color=blue><u>rules-users@lists.jboss.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><font size=3 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a><font size=3><br>
<br>
<br>
<br>
<br>
-- <br>
- </font><a href=http://salaboy.wordpress.com/ target=_blank><font size=3 color=blue><u>http://salaboy.wordpress.com</u></font></a><font size=3><br>
- </font><a href=http://www.jbug.com.ar/ target=_blank><font size=3 color=blue><u>http://www.jbug.com.ar</u></font></a><font size=3><br>
- Salatino "Salaboy" Mauricio - <br>
<br>
_______________________________________________<br>
rules-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org" target=_blank><font size=3 color=blue><u>rules-users@lists.jboss.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><font size=3 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a><font size=3><br>
</font><tt><font size=2><br>
_______________________________________________<br>
rules-users mailing list</font></tt><tt><font size=2 color=blue><u><br>
</u></font></tt><a href="mailto:rules-users@lists.jboss.org" target=_blank><tt><font size=2 color=blue><u>rules-users@lists.jboss.org</u></font></tt></a><tt><font size=2 color=blue><u><br>
</u></font></tt><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><tt><font size=2 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></tt></a><font size=3><br>
</font>
<p><font size=3><br>
_______________________________________________<br>
rules-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org"><font size=3 color=blue><u>rules-users@lists.jboss.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank><font size=3 color=blue><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a><font size=3><br>
</font>
<br><tt><font size=2>_______________________________________________<br>
rules-users mailing list<br>
rules-users@lists.jboss.org<br>
https://lists.jboss.org/mailman/listinfo/rules-users<br>
</font></tt>
<br>