[JBoss JIRA] (DROOLS-1647) DataSource aren't corrctly bound to executor during runUntilHalt
by Tibor Zimányi (Jira)
[ https://issues.jboss.org/browse/DROOLS-1647?page=com.atlassian.jira.plugi... ]
Tibor Zimányi updated DROOLS-1647:
----------------------------------
Labels: ruleunits (was: )
> DataSource aren't corrctly bound to executor during runUntilHalt
> ----------------------------------------------------------------
>
> Key: DROOLS-1647
> URL: https://issues.jboss.org/browse/DROOLS-1647
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Reporter: Mario Fusco
> Assignee: Mario Fusco
> Priority: Major
> Labels: ruleunits
> Fix For: 7.1.0.Final
>
>
> DataSource aren't corrctly bound to executor during runUntilHalt causing the following test case to not complete as expected
> {code}
> @Test(timeout = 10000L)
> public void testReactiveOnUnitCreatingDataSource() throws Exception {
> String drl1 =
> "package org.drools.compiler.integrationtests\n" +
> "unit " + getCanonicalSimpleName( AdultUnitCreatingDataSource.class ) + "\n" +
> "import " + Person.class.getCanonicalName() + "\n" +
> "import " + ReactiveAdultUnit.class.getCanonicalName() + "\n" +
> "rule Adult when\n" +
> " Person(age >= 18, $name : name) from persons\n" +
> "then\n" +
> " System.out.println($name + \" is adult\");" +
> " list.add($name);\n" +
> "end";
> KieBase kbase = new KieHelper().addContent( drl1, ResourceType.DRL ).build();
> RuleUnitExecutor executor = RuleUnitExecutor.create().bind( kbase );
> DebugList<String> list = new DebugList<>();
> executor.bindVariable( "list", list );
> AdultUnitCreatingDataSource adultUnit = new AdultUnitCreatingDataSource(list);
> adultUnit.insertPerson( new Person( "Mario", 42 ) );
> Semaphore ready = new Semaphore( 0, true);
> list.onItemAdded = ( l -> ready.release() );
> new Thread( () -> executor.runUntilHalt( adultUnit ) ).start();
> ready.acquire();
> assertEquals( 1, list.size() );
> assertEquals( "Mario", list.get(0) );
> list.clear();
> list.onItemAdded = ( l -> ready.release() );
> adultUnit.insertPerson( new Person( "Sofia", 4 ) );
> adultUnit.insertPerson( new Person( "Marilena", 44 ) );
> ready.acquire();
> assertEquals( 1, list.size() );
> assertEquals( "Marilena", list.get(0) );
> executor.halt();
> }
> public static class AdultUnitCreatingDataSource implements RuleUnit {
> private final DataSource<Person> persons;
> private final List<String> list;
> public AdultUnitCreatingDataSource( List<String> list ) {
> this.persons = DataSource.create();
> this.list = list;
> }
> public DataSource<Person> getPersons() {
> return persons;
> }
> public List<String> getList() {
> return list;
> }
> public void insertPerson(Person person) {
> persons.insert( person );
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 8 months
[JBoss JIRA] (DROOLS-2183) Can't configure KieSession used in RuleUnitExecutor
by Tibor Zimányi (Jira)
[ https://issues.jboss.org/browse/DROOLS-2183?page=com.atlassian.jira.plugi... ]
Tibor Zimányi updated DROOLS-2183:
----------------------------------
Labels: ruleunits (was: )
> Can't configure KieSession used in RuleUnitExecutor
> ---------------------------------------------------
>
> Key: DROOLS-2183
> URL: https://issues.jboss.org/browse/DROOLS-2183
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.5.0.Final
> Environment: macOS 10.12.6, Oracle Hotspot 1.8.0_151
> Reporter: Duncan Doyle
> Assignee: Mario Fusco
> Priority: Major
> Labels: ruleunits
>
> To support CEP using RuleUnits, we need to be able to configure a session that uses the PseudoClock (a best practice when using deterministic CEP rule execution). However, in the current implementation, the KieSession configuration in kmodule.xml is discarded. Second, there is not a nice way in the current API to pass session configuration programmatically.
> A reproducer of the problem can be found here (sorry for not cleaning it up nicely. It basically tries to set the SessionClock as fact into WorkingMemory, and at that time trying to cast to SessionPseudoClock.): https://github.com/DuncanDoyle/rule-unit-and-session-conf
> Just run "mvn clean test" on that project.
> As discussed on IRC, we agreed that the proper way of doing this would be to make the RuleUnitExecutor a container resource and allow it to use session configuration defined in kmodule.xml (also from a KIE-Server perspective).
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 8 months