Flows, Subflows and fault.
by Swindells, Thomas
I've just started to use Drools Flow in anger and I'm really struggling to understand the correct way to use it and think I am missing something.
This is what I want to achieve:
The app code executes a StartProcess command and waits for the process to return (1 main process per session, 1 session per thread).
The process either succeeds, or it fails with a result.
A process could be complicated so I want to split it up into a parent process calling subprocesses.
I want to minimize boilerplate code (particularly in the ruleflow files) and keep the workflows as simple and maintainable as possible.
It sounds simple enough and doesn't seem to be particularly unusual.
Issue 1: startProcess is semi-synchronous. It starts the process, runs through as many nodes as it can until it gets to a non-synchronous task (rules, long lived customer work item etc) at which point it returns - or it returns when the entire process has been completed.
Challenge 1a: How to detect when the process has finished and use it in a synchronous manner.
Solution: A ProcessEventListener which completes a countdown latch when teh process has completed.
Challenge 1b: Subprocesses also trigger process events
Solution: Have the latch track the first process that started (the parent) and only return when that process completes.
Issue 2: Drools Flow is littered with error checking code which just prints to System.err and either carrys on or just stop. Eg if a work item handler isn't registered the process just stalls with a message.
Solution: Make sure code is perfectly written and doesn't have any bugs... hope that it doesn't happen in production ... complain on mailing list and add TODO to raise issue.
Issue 3: Fault nodes seem to be the correct way to say that something has gone wrong and the process should terminate.
Challenge: How does the calling code actually work out what the fault was and get the variable? The guide talks very very briefly about exception handlers but from what I can understand this is a way for the process to define what to do in this conditions. I want the process to be aborted and the calling application to be informed of this and the details.
Solution: Add an event listener which detects when a fault node is being entered and extracts the details - seems like a big hack surely there is a better way.
Issue 4: If a child process executes a fault node it is aborted. The parent process is set to wait for completion and has the child node as not being independent so I would expect that the parent process should also be marked as aborted.
Challenge: The parent process isn't marked as complete - it still has a status of Executing. However the process is stalled. Looking at subprocessNodeInstance internalTrigger (line 117) if the node returns a state of completed then trigger completed is called, otherwise it just adds a process listener - which will never be called as the process has already aborted. The parent process just stalls left in the state of active forever.
Sollution: ?? Hack my fault listener to work round the issue and update the parent process, make the processEventListener assert that if a child process is aborted then we should return? Ask on the mailing list to get me out of a blind alley and point me to the correct drools way of doing it...
Thomas
________________________________
**************************************************************************************
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
**************************************************************************************
15 years, 7 months
mavn drools 5.1 plug-in
by Kumar, Ravendra
Hi all,
Could any of you please suggest best maven plug-in to build/compile .drl
files for drools 5?
Thanks
Ravendra
Please help Logica to respect the environment by not printing this email / Pour contribuer comme Logica au respect de l'environnement, merci de ne pas imprimer ce mail / Bitte drucken Sie diese Nachricht nicht aus und helfen Sie so Logica dabei, die Umwelt zu sch�tzen. / Por favor ajude a Logica a respeitar o ambiente nao imprimindo este correio electronico.
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
15 years, 7 months
List of valid values
by Chris Selwyn
I am developing a set of rules around validating messages in a B2B
messaging environment and I would like to have my rules builders have
control of the valid set of values for a particular field preferably
without creating a new fact model.
Since I am working in a B2B messaging world, I can see how to define an
enumeration in an XSD and how to access those in the Guvnor to create a
dropdown menu.
I can also see how to define a set of enumeration values in the Guvnor
which uses a hardcoded set of values to define the legal values for
populating a dropdown menu.
I can even see how to have the dropdown menu populated from a Java
class. The class appears to have to be on the classpath of the
application... It is not good enough to make it be part of the jar that
contains the fact model. This means that the set of legal values is part
of the "technical" domain rather than the "business" domain. I guess I
can always have the class load the values from a database, properties
file or some such but that means a separate place to store the values.
However, I feel that I would like to have the set of valid values be
part of what is accessible and configurable through the Guvnor.
Is there somewhere I can store the set as an artefact in Guvnor and be
accessible at runtime for me to do the check with?
Or should I just code the values into a set in a function?
Chris Selwyn
15 years, 7 months
Drools API
by shyam_prakash
Hello,
I am looking for a way to expose the published rule sets programmatically
and I am trying to determine if there is a service API that can be used to
retrieve the list/or iterate through published packages.
Please let me know if there is any such API / Javadoc for the same.
Thanks,
Shyam
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-API-tp1724208p...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Can Guvnor's repository functionality be exposed as a web service? [was: Drools API]
by Wolfgang Laun
[I'm re-posting this as a new thread with an apt subject on behalf of Patricia]
This is the scenario that I am looking for:
I am using Drools Guvnor as the central rule repository. I also have
an external application, that has a custom rule editor in place, and
users can create rules. This custom rule editor will take care of
Conditional Elements and Consequence actions. I would like to be able
to save the rule back in Guvnor, as that is the rule repository.
In the docs, there says that Guvnor has 2 parts: front-end and
backend. The backend includes the repository access as well. My
question is if the Guvnor backend exposes the repository functionality
as web service, or if it can be easily exposed.
Thanks,
Patricia
15 years, 7 months
RuleAgent to KnowledgeAgent(org.drools.definition.rule.Rule to org.drools.rule.Rule)
by Kinjal Khandhar
Hi All,
I want to convert org.drools.definition.rule.Rule to
org.drools.rule.Rule,i.e i want to move RuleAgent to KnowledgeAgent.
I tried:
for( KnowledgePackage knowledgePackage:
session.getKnowledgeBase().getKnowledgePackages() )
{
for( Rule rule: knowledgePackage.getRules() )
{
org.drools.rule.Rule odrRule = (org.drools.rule.Rule)rule;
}
}
I get ClassCastException.Can anyone provide me with the solution/workaround.
Thanks in advance.
Regards,
Kinjal
15 years, 7 months
DrlParser problem with soundslike and matches
by Bruno Freudensprung
Hi,
I am using Drools 5.1.1 (but also tried with 5.2.0.SNAPSHOT) to achieve
the following scenario:
1 - use the Drools' Eclipse graphical rule editor to create a BRL file
2 - convert the BRL to DRL using the
org.drools.ide.common.server.util.BRXMLPersistence and
org.drools.ide.common.server.util.BRDRLPersistence classes
3 - parse the DRL with the org.drools.compiler.DrlParser class (in order
to do some things)
I have a problem with DrlParser class that does not seem to accept the
"matches" and "soundslike" operators.
With the following rule... :
rule "TestRule"
dialect "mvel"
when
Document( text soundslike "drink" )
then
// some
end
... I get that error message from the DrlParser:
src/main/resources/org/drools/lang/DescrBuilderTree.g: node from line
0:0 mismatched tree node: <unexpected:
[@15,55:64='soundslike',<83>,4:17], resync=soundslike> expecting <UP>
Does anyone has an idea of what's going on?
Many thanks,
Bruno.
15 years, 7 months
Re: [rules-users] GWT Console and WSHT Rendering
by sam.squire@paretopartners.com
Kris, thank you.
I have templates working now. I can extract the 'result' of a form by
specifying an dataOutput, dataOutputRefs and a dataOutputAssociation into
a process variable.
What is the best way to give data to a human task node? That way the form
can change depending on the state of the process itself.
In the sourcecode it looks like only a few parameter types are possible
(Comment, Content, Skippable, Priority etc..) and it seems to give the
content as context to Freemarker but it does not seem to 'see' it.
Sam Squire
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
15 years, 7 months
Performance effect due to "eval"?
by sumatheja
Hi All,
Is it true that the performance of RETE algorithm gets
affected if we use "eval" function in the rules conditions?
Can anyone explain if this is true.
--
cheers
15 years, 7 months