I have been working through the code with a debugger, it looks like this method call in
SingleSessionCommandService is what causes it to behave as if its single threaded:
public synchronized <T> T execute(Command<T> command) {
The method is synchronized, which I don't understand - but maybe that is why it is
called SingleSessionCommandService. I have tried to work around this by creating a new
session every time I need to start a new process but this causes hibernate exceptions of
this form:
2010/08/31 10:15:58.469{UTC} [AssertionFailure] [ProcessStarterThread-8]: ERROR: : an
assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to
unsafe use of the session)
org.hibernate.AssertionFailure: null id in
org.drools.persistence.processinstance.ProcessInstanceInfo entry (don't flush the
Session after an exception occurs)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:82)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190)
at
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:1057)
at
bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:430)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:173)
at
bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:104)
at
org.drools.persistence.session.JtaTransactionManager.commit(JtaTransactionManager.java:164)
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:281)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:193)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:184)
at drools.test.PersistenceTest.startProcess(PersistenceTest.java:93)
at drools.test.PersistenceTest.access$1(PersistenceTest.java:92)
at drools.test.PersistenceTest$1.run(PersistenceTest.java:67)
at java.lang.Thread.run(Thread.java:619)
So I am wondering if what I am trying to do is even supported?
From: rules-dev-bounces(a)lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] On
Behalf Of Puigdomenech, David
Sent: 31 August 2010 08:17
To: Rules Dev List
Subject: Re: [rules-dev] A drools flow persistence example thatbehaves strangely
Greg,
First of all, thank you very much for you test example.
Answering your question:
"My question is why when I change the code from running without persistence to
running with persistence does it become "single threaded"? You can see by
toggling the persistence variable in the top of the test file that when persistence is
enabled each flow will complete before the next one begins yet without persistence they
run in parallel."
We think the problem is that all the threads are waiting for getting the connection,
because of there is only one connection it becomes a shared resource.
What do you thing about?
Thanks,
David.
David Puigdomènech Blancas
Dpto. I+D Desarrollo
Logister, S.A. - GRIFOLS
Polígon Llevant
C/Palou, 6
08150 Parets del Vallès
Tel: + 34 93 571 02 78
Fax: + 34 93 571 02 94
P Do you need to print this message? Let's protect the environment.
De: rules-dev-bounces(a)lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] En nombre
de Chrystall, Greg
Enviado el: viernes, 27 de agosto de 2010 18:14
Para: Rules Dev List
Asunto: Re: [rules-dev] A drools flow persistence example thatbehaves strangely
You can download it here:
http://dl.dropbox.com/u/2634115/drools-test.zip
You can just import that project into an eclipse workspace and run the unit test, the
database should start when you do.
I am away until Tuesday next week, if you have any questions I will answer them then.
Thanks,
Greg
From: rules-dev-bounces(a)lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] On
Behalf Of Puigdomenech, David
Sent: 27 August 2010 16:20
To: Rules Dev List
Subject: Re: [rules-dev] A drools flow persistence example that behaves strangely
Please, could you be so kind to put the whole test project on an http server.
I was trying to persist the flow in a PostgreSQL database but I was receiving some
Bitronix errors.
Have ever of you persist a flow in a database different from h2?
Thank at all.
David Puigdomenech
De: rules-dev-bounces(a)lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] En nombre
de Chrystall, Greg
Enviado el: viernes, 27 de agosto de 2010 16:45
Para: Rules Dev List
Asunto: [rules-dev] A drools flow persistence example that behaves strangely
I have written a test based as much as possible on the Drools Flow 5.1 Persistence
Documentation. You can see the code here:
http://pastebin.com/33QXK4iU
And I have attached my eclipse project but without the jars as its too big, if anyone
wants a zip of the whole project ready to run, I can put it on an http server for you.
My question is why when I change the code from running without persistence to running with
persistence does it become "single threaded"? You can see by toggling the
persistence variable in the top of the test file that when persistence is enabled each
flow will complete before the next one begins yet without persistence they run in
parallel.
Any advice on what I am doing wrong or whether persistence simply does not support what I
want to do is much appreciated.
Greg
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************
La informacion contenida en el presente e-mail es confidencial y esta reservada para el
uso exclusivo de su destinatario. Se prohibe estrictamente la distribucion, copia o
utilizacion de esta informacion sin el previo permiso de su destinatario. Si usted no
fuera el destinatario, por favor notifiquelo inmediatamente al remitente y elimine el
presente mensaje de su sistema informatico.
Information contained in this e-mail is confidential and is intended for the use of the
addressee only. Any dissemination, distribution, copying or use of this communication
without prior permission of the addressee is strictly prohibited. If you are not the
intended addressee, please notify the sender immediately by reply and then delete this
message from your computer system.
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************
La información contenida en el presente e-mail es confidencial y está reservada para el
uso exclusivo de su destinatario. Se prohíbe estrictamente la distribución, copia o
utilización de esta información sin el previo permiso de su destinatario. Si usted no
fuera el destinatario, por favor notifíquelo inmediatamente al remitente y elimine el
presente mensaje de su sistema informático.
Information contained in this e-mail is confidential and is intended for the use of the
addressee only. Any dissemination, distribution, copying or use of this communication
without prior permission of the addressee is strictly prohibited. If you are not the
intended addressee, please notify the sender immediately by reply and then delete this
message from your computer system.
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************