Drools fusion how to I catch an Exception
by RichardAmbridge
If I have a rule that has an error in it, the error isn't being caught by the
compiler and the error doesn't happen as the Object is inserted into the
session, it only happens after a time period completes, then Drools silently
fails.
How can I catch these silent failures.
See below for test case.
Notice in the After5 rule there is a mistake in the then part.
m.status=$m.status;
$m doesn't exist.
If i change this to $m.status=m.status, the compiler detects the error, but
this way of m.status=$m.status is not found.
When the rule fires it just dies.
I need to be able to catch the Exception somehow and report it..
Any help really appreciated..
Thanks
Ric
----------
sample.drl:-
----------
package com.sample
import com.sample.DroolsTest.Message;
declare Message
@role ( event )
end
rule "Hello"
dialect "mvel"
when
m : Message( status == Message.HELLO, myMessage : message )
then
System.out.println( "Hello added" );
end
rule "After5"
dialect "mvel"
when
m : Message( status == Message.HELLO, myMessage : message )
not( Message( status == Message.GOODBYE , this after [0s,5s] m ))
then
System.out.println( "After5 then start" );
m.status=$m.status;
System.out.println( "After5 then stop" );
retract(m);
end
----------
DroolsTest.java:
----------
package com.sample;
import org.drools.KnowledgeBase;
/**
* This is a sample class to launch a rule.
*/
public class DroolsTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase
.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
// go !
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
System.out.println("Inserting message");
ksession.insert(message);
System.out.println("Fire all rules");
ksession.fireAllRules();
System.out.println("Sleep 10");
Thread.sleep(10000);
System.out.println("End sleep");
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBaseConfiguration conf = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM); // STREAM mode as we are
// dealing with Events
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-fusion-how-to-I-catch-an-Excepti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Fwd: how to import function in drl file on guvnor
by Michael Anstis
Forwarded to mailing list.
You would have to consider use of free-format DRL in this scenario.
---------- Forwarded message ----------
From: <avneesh.sisodia(a)intelegencia.com>
Date: 4 September 2012 12:33
Subject: how to import function in drl file on guvnor
To: michael.anstis(a)gmail.com
Hello mantis,
I am very new in drools and guvnor users. I have a problem during making
rules. I want to use my predefined functions in rule execution.
Suppose I have a rule "companyDivision" and i want to import it into my
rule file like this:
package com.exp.test
import com.abc.bean.CompanyBean
import function
com.abc.util.Validation.companyDivision;
rule "CompanyInfo"
dialect "mvel"
when
CompanyBean( businessType == "ABC" , insuranceProgram ==
"XYZ" )
then
CompanyBean fact0 = new CompanyBean();
fact0.setBusinessType( "ABC" );
fact0.setInsuranceProgram( "XYZ" );
companyDivision(fact0 );
end
How I can do this.
I am doing following steps to c\generate rules::
1. creating com.exp.test package
2. uploading jar(model) file which included all pojo files of application
3. creating "CompanyInfo" rule
rule file generated by guvnor is like this:::
package com.exp.test
import com.abc.bean.CompanyBean
rule "CompanyInfo"
dialect "mvel"
when
CompanyBean( businessType == "ABC" , insuranceProgram ==
"XYZ" )
then
CompanyBean fact0 = new CompanyBean();
fact0.setBusinessType( "ABC" );
fact0.setInsuranceProgram( "XYZ" );
insert(fact0 );
end
I have only two options there 1. insert and 2. insert logically.
but on place of insert and insert logically I want to use "companyDivision"
function.
Please guys tell me how it is possible.
Thanks
13 years, 6 months
Fwd: need help to use drools guvnor.
by Michael Anstis
Forwarded to mailing list.
You could consider using the RSS feed (
http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html) and an
adaptation of this:
https://community.jboss.org/wiki/PublishDroolsArtifactsFromAProductionEnv...
---------- Forwarded message ----------
From: <avneesh.sisodia(a)intelegencia.com>
Date: 4 September 2012 12:32
Subject: need help to use drools guvnor.
To: michael.anstis
Hey manstis,
I need your valuable help. I have a project which is based on Insurance
domain. I have to use drools-guvnor in it to execute some rules.Now I had
deploy guvnor 5.3 on JBoss AS 7.0.Final. And I am able to use static rules
from .drl file by using stateless session. I need to do it dynamic. I mean
when I changed any condition in rule file on guvnor it should be reflect on
application. So I want that you suggest me any link where I can get useful
information. how I can use rules directly from guvnor on java.
Thanks..
13 years, 6 months
IntelliFest Drools & jBPM Workshop Agenda (San Diego Oct 2012)
by Mark Proctor
http://www.dzone.com/links/r/intellifest_drools_amp_jbpm_workshop_agenda_...
---
At IntelliFest this year there are two Drools workshops. There is the "General Drools&jBPM Workshop", which is a series of high level talks explaining the various features of Drools&jBPM. The second is the workshop "Rule Design Patterns in Production Systems", by Dr Wolfgang Laun, which is aimed at rule authoring techniques. The agenda for both is below, you can see the more detailed and up to date agenda here.
Only 7 weeks to go, and there are limited spaces, so register soon here.
General Drools&jBPM Workshop
8.00 AM: Breakfast Social – pre-laptop setup, and QA time with solution Architects.
-Key will be provided to setup your laptop, so you can view and run the examples used during the talks.
9.00 BRMS Product Overview (Prakash Aradhya 15min)
How we turn the Drools and jBPM communtiy parts into a world class product. Supporting and harvesting all the innovation done in the open community, Red Hat delivers reliable, dependable and integrated solutions for enterprise customers.
9.15 Introduction to Drools Expert (Mark Proctor 45min)
Drools Expert covers the business rule engine. A gentle, example driven, dive into the Drools technical rule language and engine features.
10.10 Introduction to Drools Fusion (Edson Tirelli 45min)
Learn how Drools does CEP differently. Our unified approach extends Drools Expert with a series of language and sub-engine extensions to provide temporal reasoning and event correlation.
11.05 Introduction to jBPM and BPMN2 (Kris Verlaenen 45min)
jBPM is a BPM engine designed for flexible processes, implementing and extending the BPMN2 spec. Built form the ground up to be part of a unified strategy for business automation and decision management. jBPM fully integrates with Drools Expert and Fusion.
11.45 Decision Modelling with Graphical Editors (Edson Tirelli 30min)
Drools Expert provides sophisticated web based tooling, around decision tables, guided editors and templates. Our decision modelling approach draws from the very best research found at Dr Jan Vanthienien school of Decision Modelling.
12.30 Working Lunch – Experience Drools and jBPM – Hands on labs (Optional) (1hour)
13.30 Human Tasks up Close and Personal (Kris Verlaenen 40min)
Human tasks are a central component of BPM. This example driven talk will build an example live, demonstrating what jBPM’s Human Task technology can do for you.
14.20 Building Games with Drools – Pong, Snake and Wumpus (Mark Proctor 40min)
Time for some hard play, learn how to build classic computer games with Drools. These also provide interesting exercises in BA requirements gathering.
15.10 Drools Planner a Quick Overview (Geoffrey De Smet 40min)
Whether it’s employee rostering, task scheduling, vehicle routing, bin packing or another planning problem: all organizations try to optimize their limited resources under constraints. Drools Planner optimizes business resources for normal Java programmers.
15.50 Drools Chance for Imperfect Reasoning (Davide Sottara 40min)
Sometimes data quality is not perfect, so facts may not be known with precision and certainty. Likewise, crisp constraints such as hard thresholds might not be able to capture the complexity of a business policy. Drools Chance allows to apply gradual and/or probabilistic constraints to uncertain or vague data.
16.40 UberFire – Drools&jBPM Workbench framework (Mark Proctor 30min)
UberFire is a new project that forms the foundation of our 6.0 web tooling. It’s standalone framework that provides a sophisticated workbench framework for the web; where everything is a plugin. Come learn about the Uberfire, and how you can use the workbench to build your own web applications.
17.10 Drools&jBPM 6.0 and Beyond (Optional : open as long as people remain)
An open presentation and discussion about the design ideas, principles and goals that are driving the development of Drools & jBPM version 6.0. This will be an optional and informal session where attendees will have the opportunity to learn about what is coming, contribute ideas and provide feedback that will be taken in consideration by the development team.
17.10 Hands on Lab
Run at the same time as "Drools&jBPM and Beyond" and Beyond. Solution Architects are on hand to help you with your coding problems, and running examples.
Rule Design Patterns in Production Systems
Rule Design Patterns
What is a “Rule Design Pattern”?
Basic Rule Formats
Fact Classification
Handling Failure to Match
Extending Rules
Reasoning with Interfaces
Active Facts
Marker Facts
Fact Proxies
Application Design Patterns
Short-Term Sessions
Permanent Sessions
13 years, 6 months
Add calendars to knowledge session from Spring?
by dunnlow
I am using the Drools 5.4 integration server in a stateless session. I have
it running fine with the example. Now, I want to use custom Quartz
calendars in my rules. The only way I could come up with to do this in
Spring (a la integration server) was to create a bean that takes a ksession
constructer then creates the calendars and adds them to that ksession.
I see that the bean is created with a knowledge session and all seems ok,
but none of my calendar-based rules ever fire regardless of how the
calendars are configured. (I test the calendars in my bean (with a call to
isTimeIncluded()) and they seem to be in working order.
Also weird is that bean's constructor gets called twice and with two
different knowledge sessions. Once when I start the application, and then
again when I send to the rules service.
1) What is the right was to add custom calendars to a knowledge session (via
Spring)?
2) Any idea why my bean is getting called twice with different knowledge
sessions?
Thanks for any insight. -J
---in knowledge-service.xml
<drools:ksession id="ksession1" type="stateful" kbase="kbase1"
note="node1"/>
<bean id="myCalendar" class="org.test.MyQuartzCalendarLoader">
<constructor-arg ref="ksession1"/>
</bean>
--- MyQuartzCalendarLoader.java
public class MyQuartzCalendarLoader {
private static StatefulKnowledgeSession thisSession=null;
public MyQuartzCalendarLoader (StatefulKnowledgeSession thisKs) {
//gets called twice?
thisSession=thisKs;
print thisSession.tostring() -- looks ok
WeeklyCalendar calendar = new WeeklyCalendar();
org.drools.time.Calendar onlyWeekDays =
QuartzHelper.quartzCalendarAdapter(calendar);
calendar.setDayExcluded(Calendar.WEDNESDAY,false) -- I toggle
just to test
print onlyWeekDays.isTimeIncluded(now.getTime()); --- also
works as expected
Calendars cals =
thisSession.getCalendars().set("ONLYWEEKDAYS",onlyWeekDays);
}
}
--- test.drl
rule "weekdays" dialect "mvel" <-- This rule never fires unless i
remove calendars.
calendars "ONLYWEEKDAYS"
when
$m:Message()
then
$m.text = "FIRED"
end
--
View this message in context: http://drools.46999.n3.nabble.com/Add-calendars-to-knowledge-session-from...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Reg. Iterating over a list
by Phani Saripalli
Hi.
I tried to identify relevant ways for some container specific operations
like exists, forall (or foreach). Basically I have started using for
software product line research, and specifically model checking over product
line models. The initial results so fat ( considering the time I started)
have been wonderful, alas I am tuck at this point.
For example, consider :
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
declare Project
a : int
b : int = 5
list : List = new java.util.ArrayList(java.util.Arrays.asList(1 , 2 , 3
, 4 , 5))
end
Now that the element of Project - list is configured, I would like to
perform some operations on it like:
a) for each - for the list (Project - P; P.list), is each element is greater
than 2? (or in essence - evaluating each element using a boolean
expression).
b) Similarly, a function like exists . for the list, is there any element
for which this expression is satisfied -
t > 2 && t < 5, where t is the iterator for the list.
As the elements of the lists are mere numbers (in this case ints), I am not
really aware/clear how I can use the Drools operations collect, for all etc.
Previously I worked with Jess rule engine, and it has in built lambda
functions which nicely provides list iterators and thus evaluating each
element of the list against a boolean expression.
I am at a very important point in my work, and any hint or solution will be
highly appreciated.
Many thanks :)
Phani
--
View this message in context: http://drools.46999.n3.nabble.com/Reg-Iterating-over-a-list-tp4019512.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
2nd CFP Semantic Web Applications and Tools for the Life Sciences (SWAT4LS 2012)
by Adrian Paschke
2nd Call for Papers - Submission Deadline in 3 Weeks
5th International Workshop on Semantic Web Applications and Tools for the Life Sciences (SWAT4LS 2012)
http://www.swat4ls.org/workshops/paris2012
**** NEWS ****
Submission system has been opened - submission deadline in 3 weeks!
http://www.easychair.org/conferences/?conf=swat4ls2012
First program structure, keynotes & tutorials announced
http://www.swat4ls.org/workshops/paris2012/scientific-programme/
Overview
Since 2008, SWAT4LS is a workshop that has provided a platform for the
presentation and discussion of the benefits and limits of applying web-based
information systems and semantic technologies in the domains of health care
and life sciences.
SWAT4LS has been in Edinburgh (2008), Amsterdam (2009), Berlin (2010) and
London (2011).
Growing steadily each year as Semantic Web applications have become more
widespread, the program of SWAT4LS has grown to include associated events.
The next edition of SWAT4LS will be held in Paris, on November 30th 2012,
and it will be preceded by two days of tutorials and hackathons.
We are confident that the next edition of SWAT4LS will provide the same open
and stimulating environment that brought together researchers, developers,
and users, from various fields including biomedical informatics, systems
biology, computational biology, drug discovery, bioinformatics and
biocomputing, to discuss goals, current limits and real experiences in the
use of Semantic Web technologies in Life Sciences.
________________________________________
Rationale
The web is a key medium for information publishing, and web-based
information systems play a key role in biomedical information exchange and
integration. At the same time, the variety and complexity of biomedical
information call for the adoption of semantic-based solutions.
The Semantic Web provides a set of technologies and standards that are key
to support semantic markup, ontology development, distributed information
resources and collaborative social environments.
Altogether the adoption of the web-based semantic-enabled technologies in
the Life Sciences has potential impact on the future of publishing,
biological research and medicine. This workshop will provide a venue to
present and discuss benefits and limits of the adoption of these
technologies and tools in biomedical informatics and computational biology.
It will showcase experiences, information resources, tools development and
applications. It will bring together researchers, both developers and users,
from the various fields of Biology, Bioinformatics and Computer Science, to
discuss goals, current limits and some real use cases for Semantic Web
technologies in Life Sciences.
________________________________________
Topics
Topics of interest include, but are not limited to:
Standards, Technologies, Tools for the Semantic Web:
- Big Metadata
- Semantic Web standards and new proposals (e.g.: RDF, OWL, SKOS, SPIN,
RuleML, Microformats)
- Tools for ontology editing, annotation, versioning and provenance
management
- RDF stores, NoSQL, reasoners, query and visualization systems
- Knowledge representation for biomedical knowledge bases
- Query federation systems for distributed knowledge and data discovery
- Tools for semantics-enabled web publication
Systems for a Semantic Web for Bioinformatics:
- Biomedical knowledge bases on the Semantic Web
- Semantic biomedical Web Services
- Semantics-enabled biomedical information systems and solutions
- Linked Data for biomedical research
- Semantic Scientific Workflow Systems
Existing and prospective applications of the Semantic Web for
Bioinformatics:
- Semantic Wikis
- Semantic collaborative research environments
- Semantic crowdsourcing and collective intelligence
- Alternative approaches to biomedical metadata generation and management
- Methods for data sharing and open data
- Approaches to data privacy and security
- Case studies, use cases, and scenarios
________________________________________
Type of contributions
The following possible contributions are sought:
- Research papers
- Position papers
- Posters
- Software demos
________________________________________
Proceedings
Proceedings of SWAT4LS will be published in CEUR Workshop proceedings.
Please refer to the SWAT4LS website for detailed formatting instructions
prior to submission:
http://www.swat4ls.org/workshops/paris2012/call/
________________________________________
Special issue
Authors of accepted contributions to the upcoming edition of SWAT4LS will be
invited to submit to a special issue of the BMC Journal of Biomedical
Semantics.
________________________________________
Deadlines
Expression of interest for tutorials: 5th July 2012
Submission opening: 3rd September 2012
Papers submission deadline (abstracts): 28th September 2012
Papers submission deadline (full text): 9th October 2012
Early registration deadline: 15th October 2012
Posters and demos submission deadline: 22nd October 2012
Communication of acceptance: 29th October 2012
PDF ready: 23rd November 2011
Hackathon, Tutorials 28-29th November 2012
Workshop day: 30th November 2012
________________________________________
Instructions:
All papers and posters must be in English and submitted in pdf format.
Submissions for papers should report original research, and should be
between 8 and 15 pages.
Submissions for position papers should report qualified opinions,
recommendations or conclusions, and should be between 3 and 6 pages.
Submissions for posters should be between 2 and 4 pages.
Submissions for software demo proposals should also be between 2 and 4
pages.
Please refer to the SWAT4LS website for detailed formatting instructions
prior to submission:
http://www.swat4ls.org/workshops/paris2012/call/
________________________________________
Submission
All submissions will be handled via the EasyChair submission system
http://www.easychair.org/conferences/?conf=swat4ls2012
To ensure high quality, submitted papers will be carefully peer-reviewed by
at least three members of the Scientific Committee.
13 years, 6 months
Without salience
by salt
Hi All,
For the below use case i have implemented the rule. Please suggest other way
of doing without salience.
scenario
ITEMS AMOUNT OCCNO
PASS 10 1
FAIL 10 2
PASS 15 3
PASS 25 4
rule "HelloWorld_14"
salience (65522- $list.indexOf( $transdet1 ))
when
$p1:Passes($list : transaction)
$trans1:Transaction(items in ("PASS")) from $list
$p2:Passes()
not(exists($transdet5:Transaction(items in
("FAIL"),value==$transdet1.getVaue(), occno>$trans1.getOccno()) from
$p2.transaction))
then
System.out.println($trans1.getOccno());
end
The above will return
3
4 (not 4,3)
Kindly suggest other way of doing this without salience.
Thanks
Salt
--
View this message in context: http://drools.46999.n3.nabble.com/Without-salience-tp4019565.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months