Drools 5.1 Flow in a "Clustered" environment
by Ken Young
We are looking at embedding Drools 5.1 (specifically Drools Flow) in our application, but I am coming up short on determining how to configure clustering, or the support.
Specifically, I want to ensure that background processes that are taking place (reminders, timers, etc.) only happen once on a cluster. Does drools support this and how?
In other software that we have clustered (Quartz for example), where a shared database lock is used to ensure the the processing happens in one place. I was wondering if Drools 5.1 worked in a similar fashion.
Thanks
Ken
15 years, 5 months
importing functions in rules
by Samuli Saarinen
Hello,
Using mvel dialect in rules I'm getting rule compilation errors
depending on the way I import functions. I have the following rule:
rule "R1"
dialect "mvel"
when
then
test()
end
Using import function com.test.Functions.test compiles and runs fine.
but using import function com.test.Functions.* causes the compilation to
fail with the following message:
Unable to build expression for 'consequence': [Error: Failed to compile:
1 compilation error(s):
- (1,6) unable to resolve method using strict-mode:
java.lang.Object.test()]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0] ' test();
' : [Rule name='R1']
If I set the dialect to java it works in both ways. Is this expected
behavior?
Cheers,
Samuli
--
Remion Oy Etävalvontajärjestelmät liiketoiminnan
Samuli Saarinen tehostamiseen
gsm +358 (0)50 3560075
fax +358 (0)3 2125064 www.remion.com
15 years, 5 months
Question about Rete Tree example with NotNode in "Drools JBoss Rules 5.0 Developers Guide"
by Tina Vießmann
Hi,
I'm working through the explanations about Rete Trees in chapter 12 of
"Drools JBoss Rules 5.0 Developers Guide" on page 264-265. I have a
problem in understanding the input of the NotNode.
The rule says:
when
$address : Address ( addressLine == "Rossa Avenue" )
not (
$account : Account ( balance < 100 ) and
Customer ( accounts contains $account )
)
then
...
The related figure shows:
1. The Address object being processed and a tuple will be created by a
LeftInputAdapterNode.
2. The tuple of 1. will be joined with the Account fact with no
constraints (so that there's a tuple of size two?).
3. The tuple of 2. will be joined with the Customer fact with the
restriction 'accounts contains $account'. (That results in a tuple with
size 3!?)
4. The tuple of 3. will then be processed by a RightInputAdapterNode.
5. The tuple/fact from 3. will be processed using a NotNode together
with the Address-tuple from 1.
I don't understand while the tuple from 1. will in step 2 be joined with
the Account fact. I would have expected something like:
1. // same
2. The Account fact will be processed and a tuple will be created by a
LeftInputAdapterNode.
3. The Customer fact will be joined with the Account tuple with the
constraint 'accounts contains $address'. Resulting in a tuple.
4. // somehow the tuple from step 3 will be negated and joined with the
tuple from step 1.
Could anybody explain to me why it's done the way its drawn in the book?
Thank you! :)
Tina
15 years, 5 months
What's wrong with this rule
by 赵侃侃
Hello,
With the help from the community I managed to get my first rule working, and
I'm trying to write my second rule on my own but it just doesn't seem to
work correctly.
Here is the scenario, what I want is to identify a pattern that there's no
EventB coming in within 2 minutes with a particular index value.
For example, EventB would have a property named index and assume the value
of index would be either 0 or 1.
Before firing the rules, I would manually insert facts of possibleIndex with
value 0 and 1 into the workingMemory.
Within 2 minutes, if there only comes one EventB with index valued 0 then
the system should report no EventB coming in with index value 1 in last 2
minutes.
Vice versa, in the case of only coming one EventB with index valued 1 then
the system should report no EventB coming in with index value 0 in last 2
minutes.
If within 2 minutes, there comes 2 EventB with both value 0 and 1 then
nothing should report.
Here is what I wrote, but it doesn't seem to work correctly.
I used a timer to fire this rule every 10 seconds because I don't think the
rule would run automatically if I don't add that. (not too sure though)
rule "no B in 2 minutes"
timer (0 10s)
when
possibleIndex( $index : index ) from entry-point "Event stream"
$p : PatternConsumer ( name == 'no B' && index == $index )
not ( EventB( index == $index && this after[0ms,2m] $p) over window:time(2m)
from entry-point "Event stream" )
then
PatternConsumer pc = new PatternConsumer( "no B", $index );
insert(pc);
System.out.println("no B in 2 minutes " + $index);
end
Best Regards,
Kevin Zhao
15 years, 5 months
Internal error in Drools Plugin
by marc.schneiderman
Environment
-----------------
Windows 7 64bit
Java 1.6 JRE
Eclipse SDK 3.5.2
GEF 3.5.2
Drools 5.1 GA Eclipse Workbench
When importing a very simple drools project ( a personal implementation of
the classic fibonacci problem), which had worked fine without any build or
runtime errors when using drools 5.0, I received the following two build
errors in the Eclipse environment. I tried looking on the Nabble news group
but did not find any similar postings. Also Googled the errors but to no
avail. Any help would be very much appreciated. Thanks.
ERROR #1
-----------
Internal error in Drools plugin:
org.drools.RuntimeDroolsException: value '1.4' is not a valid language level
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setJavaLanguageLevel(JavaDialectConfiguration.java:79)
at org.drools.eclipse.DroolsEclipsePlugin.generateParsedResource(Unknown
Source)
at org.drools.eclipse.DroolsEclipsePlugin.generateParsedResource(Unknown
Source)
at org.drools.eclipse.DroolsEclipsePlugin.parseResource(Unknown Source)
at
org.drools.eclipse.editors.DroolsLineBreakpointAdapter.canToggleLineBreakpoints(Unknown
Source)
at
org.eclipse.debug.ui.actions.ToggleBreakpointAction.update(ToggleBreakpointAction.java:187)
at
org.eclipse.ui.texteditor.AbstractRulerActionDelegate.update(AbstractRulerActionDelegate.java:132)
at
org.eclipse.ui.texteditor.AbstractRulerActionDelegate.setActiveEditor(AbstractRulerActionDelegate.java:89)
at
org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate.setActiveEditor(RulerToggleBreakpointActionDelegate.java:98)
at
org.eclipse.ui.internal.EditorPluginAction.editorChanged(EditorPluginAction.java:75)
at
org.eclipse.ui.internal.EditorActionBuilder$EditorContribution.editorChanged(EditorActionBuilder.java:83)
at
org.eclipse.ui.internal.EditorActionBuilder$ExternalContributor.setActiveEditor(EditorActionBuilder.java:129)
at
org.eclipse.ui.internal.EditorActionBars.partChanged(EditorActionBars.java:345)
at org.eclipse.ui.internal.WorkbenchPage$3.run(WorkbenchPage.java:632)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:888)
at
org.eclipse.ui.internal.WorkbenchPage.activatePart(WorkbenchPage.java:621)
at
org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3527)
at org.eclipse.ui.internal.WorkbenchPage.activate(WorkbenchPage.java:614)
at
org.eclipse.ui.internal.WorkbenchPage.showEditor(WorkbenchPage.java:2943)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2843)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2676)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:1105)
at
org.eclipse.ui.internal.views.markers.ExtendedMarkersView.openMarkerInEditor(ExtendedMarkersView.java:254)
at
org.eclipse.ui.internal.views.markers.ExtendedMarkersView.openSelectedMarkers(ExtendedMarkersView.java:1572)
at
org.eclipse.ui.internal.views.markers.ExtendedMarkersView$4.open(ExtendedMarkersView.java:568)
at
org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
at
org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:842)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:888)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at
org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:840)
at
org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1101)
at
org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1205)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
ERROR #2
----------
Unable to create view ID org.eclipse.ui.views.ContentOutline: value '1.4' is
not a valid language level:
org.drools.RuntimeDroolsException: value '1.4' is not a valid language level
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setJavaLanguageLevel(JavaDialectConfiguration.java:79)
at org.drools.eclipse.DroolsEclipsePlugin.generateParsedResource(Unknown
Source)
at org.drools.eclipse.DroolsEclipsePlugin.parseResource(Unknown Source)
at
org.drools.eclipse.editors.outline.RuleContentOutlinePage.initRules(Unknown
Source)
at org.drools.eclipse.editors.outline.RuleContentOutlinePage.update(Unknown
Source)
at
org.drools.eclipse.editors.outline.RuleContentOutlinePage.createControl(Unknown
Source)
at
org.eclipse.ui.views.contentoutline.ContentOutline.doCreatePage(ContentOutline.java:137)
at org.eclipse.ui.part.PageBookView.createPage(PageBookView.java:409)
at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:752)
at org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookView.java:921)
at org.eclipse.ui.part.PageBookView.createPartControl(PageBookView.java:492)
at
org.eclipse.ui.views.contentoutline.ContentOutline.createPartControl(ContentOutline.java:121)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:367)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:226)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:529)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:668)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:576)
at
org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568)
at
org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:272)
at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:982)
at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2626)
at org.eclipse.ui.internal.WorkbenchWindow$27.run(WorkbenchWindow.java:2965)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2946)
at
org.eclipse.ui.internal.WorkbenchWindow$21.runWithException(WorkbenchWindow.java:2263)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3506)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at
org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1384)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3506)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Internal-error-in-Dro...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Equality vs Equality
by H.C.
We have the potential for duplicate data and so we have some rules we wrote
to de-dupe things. We are attempting the check if we have two different
objects in memory but they equal each other by equals(). We have overridden
equal() and hashCode() in all our classes.
I came a cross two variations of the same de-duping rule that yields
different results but to me seems logically equivalent. How do these two
rules apply equality differently?
v1:
<code>rule "Ensure no ConfigurationEntities are duplicates of others"
when
$config1 : ConfigurationEntity( )
$config2 : ConfigurationEntity( eval( $config1 != $config2 ) && this ==
$config1 )
then
errorList.add( new ConfigError( ConfigErrorCodes.DUPLICATE_CONFIGURATION,
$config1 ));
end</code>
v2:
<code>rule "Ensure no ConfigurationEntities are duplicates of others"
when
$config1 : ConfigurationEntity( )
$config2 : ConfigurationEntity( )
eval( $config1 != $config2 && $config2.equals($config1) )
then
errorList.add( new ConfigError( ConfigErrorCodes.DUPLICATE_CONFIGURATION,
$config1 ));
end</code>
Our understanding is that:
1. eval( $config1 != $config2 ) compares the memory reference
2. this == $config1 is the same thing as eval( $config2.equals($config1) )
Given our disparate results, our assumptions must be wrong somewhere. Would
very much appreciate some insight.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Equality-vs-Equality-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
check if a
by Tina Vießmann
Is it possible to write the following conditions without using eval?
$object : MyObject ( $valueList : valueList ) // of type List
$ value : Value ( // other restrictions
&& eval( !($valueList.contains($value)) ) )
Thank you :)
Tina
15 years, 5 months
Re: [rules-users] check if a
by Greg Barton
$value : Value( $value : value, // other restrictions )
$object : MyObject( $value not memberOf valueList )
GreG
On Nov 1, 2010, at 9:55, Tina Vießmann <tviessmann(a)stud.hs-bremen.de> wrote:
Is it possible to write the following conditions without using eval?
$object : MyObject ( $valueList : valueList ) // of type List
$ value : Value ( // other restrictions
&& eval( !($valueList.contains($value)) ) )
Thank you :)
Tina
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 5 months
DrlParser with "Unknown error while parsing..."
by Wolfgang Laun
Trying to parse an absolutely correct DRL (a regular build succeeds)...
DrlParser parser = new DrlParser();
FileReader fr = new FileReader( "some.drl" );
// ... read file, create String
String drl = ...
PackageDescr pd = parser.parse( true, drl );
if( pd == null ){
System.out.println( "pd id null!" );
System.out.println( parser.getErrors() );
} else {
...
}
...and the error is:
pd id null!
[[-1,0]: Unknown error while parsing. This is a bug. Please contact the
Development team.]
?
-W
15 years, 5 months
Drools Flow in EJBs
by tizo
Hi there,
I have seen in chapter 6 of the documentation, that Drools Flow can be
configured to use JPA and transactions to persist the running states.
However, I am in a EJB where I obtain entity managers with a
@PersistenceContext annotation, and the transactions are managed by the
container, whereas in the example an EntityManagerFactory and a
TransactionManager are used.
Could I configure Flow in a direct way to be used by my EJB?
Thanks very much,
tizo
15 years, 5 months