Email Service
by ANJALI
Hi guys,
Iam trying to send email through drools by using bpmn.xml...in
order to do so i need to register a work item handler into my session.
I have done in this way
ksession.getWorkItemManager().registerWorkItemHandler("Email",
emailWorkItemHandler);
And this is my class for that handler
public class NotificationWorkItemHandler implements
WorkItemHandler {
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
// extract parameters
String from = (String) workItem.getParameter("From");
String to = (String) workItem.getParameter("To");
String message = (String) workItem.getParameter("Message");
String priority = (String) workItem.getParameter("Priority");
// send email
*EmailService service =
ServiceRegistry.getInstance().getEmailService();*
service.sendEmail(from, to, "Notification", message);
// notify manager that work item has been completed
manager.completeWorkItem(workItem.getId(), null);
}
My issue is Email service need some import but I cant see what needs to be
included....
Could any one help me out in this issue?
Thanks in advance
Anjali
--
View this message in context: http://drools.46999.n3.nabble.com/Email-Service-tp3506142p3506142.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
[rule engine advantage?]Logic and Data Separation - how to archieve the transparent domain/fact object insertion?
by kapokfly
Logic and Data Separation
Your data is in your domain objects, the logic is in the rules. This is
fundamentally breaking the
OO coupling of data and logic, which can be an advantage or a disadvantage
depending on
your point of view. The upshot is that the logic can be much easier to
maintain as there are
changes in the future, as the logic is all laid out in rules. This can be
especially true if the logic
is cross-domain or multi-domain logic. Instead of the logic being spread
across many domain
objects or controllers, it can all be organized in one or more very distinct
rules files.
------------------------
The current practice we are following demonstrate a strong relationship
between fact objects and the rule files itself, the rule needs to understand
what fact object available in the working memory and the working memory may
also consider what kind of rules can be written against objects in memory
thus the application developers need insert/write rules carefully and better
to be done by 1 developer (or we can say, depends on how the rule is
written, it will impact what objects/how objects are being inserted into the
working memory).
Can someone share their experiences how to make the knowledge session/fact
object maintenance work as transparent as possible? how to decouple the fact
object maintenance work from the rules? At which layer you usually insert
fact object to the work memory?
Ivan
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/rule-engine-advantage-Logic-and-Data-Se...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
Help needed - Repository not getting initialised?
by Praveen
Hi,
Repository is not getting initialised, throws NPE.
Please advise.
TIA.
public static Repository repository;
public static Session getSession() throws Exception {
return getSession(true);
}
public static synchronized Session getSession(boolean erase) {
try {
if (repository == null) {
if (erase) {
File repoDir = new File("repository");
System.out.println("DELETE test repo dir: "
+ repoDir.getAbsolutePath());
RepositorySessionUtil.deleteDir(repoDir);
System.out.println("TEST repo dir deleted.");
}
JCRRepositoryConfigurator config = new
JackrabbitRepositoryConfigurator();
String home = System
.getProperty("guvnor.repository.dir");
repository = config.getJCRRepository(home);
Session testSession = repository
.login(new SimpleCredentials("alan_parsons",
"password".toCharArray()));
RulesRepositoryAdministrator admin = new
RulesRepositoryAdministrator(
testSession);
if (erase && admin.isRepositoryInitialized()) {
admin.clearRulesRepository();
}
config.setupRulesRepository(testSession);
return testSession;
} else {
return repository.login(new SimpleCredentials(
"alan_parsons", "password".toCharArray()));
}
} catch (RepositoryException e) {
throw new IllegalStateException(e);
}
}
public static void main(String [] args) throws Exception{
getSession();
}
Below is the exception..
DELETE test repo dir: D:\drools\TestRepository\repository
TEST repo dir deleted.
Exception in thread "main" java.lang.NullPointerException: dispatcher
at
org.apache.jackrabbit.core.observation.ObservationManagerImpl.<init>(ObservationManagerImpl.java:97)
at
org.apache.jackrabbit.core.WorkspaceImpl.getObservationManager(WorkspaceImpl.java:748)
at
org.apache.jackrabbit.core.SessionImpl.removeRegisteredEventListeners(SessionImpl.java:1193)
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:1222)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.doDispose(RepositoryImpl.java:2194)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.dispose(RepositoryImpl.java:2149)
at
org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1175)
at
org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1127)
at
org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:544)
at
org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:366)
at
org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:673)
at
org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
at
org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
at
org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
at
org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
at Hello.getSession(Hello.java:50)
at Hello.getSession(Hello.java:27)
at Hello.main(Hello.java:72)
Regards,
Praveen.
--
View this message in context: http://drools.46999.n3.nabble.com/Help-needed-Repository-not-getting-init...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
discrepency between drools eclipse editor and runtime
by sam prar
Hi,
I have a simple drl written using the eclipse drools editor.
-----------
package com.x.workflow
import com.x.api.dto.User;
rule "validate_user"
when
userX : User(getName().equals("test123"))
then
userX.setDescription("changed in workflow)";
System.out.println("user is test123");
end
--------
The editor does not flag any errors, but, when I run the workflow through
my webapp, I see the following error :
Rule Compilation error : [Rule name='validate_user']
com/x/workflow/Rule_validate_user.java (7:439) : Syntax error, insert
")" to complete Expression
904224 [tomcat-http--51] ERROR
org.activiti.engine.impl.interceptor.CommandContext - Error while closing
command context
java.lang.IllegalArgumentException: Could not parse knowledge.
at
org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67)
at
org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:61)
the java file Rule_validate_user.java is not written by me, in fact I
cannot locate it in my source.
It appears it is generated by drools engine.
And, I cannot find what is wrong with my drl file from the error printed.
Appreciate any pointers.
thanks
sapra
14 years, 2 months
discrepency between drools eclipse editor and runtime
by saprar
Hi,
I am trying to work with Activiti and drools. I am new to both.
I have a simple drl written using the eclipse drools editor.
-----------
package com.x.workflow
import com.x.api.dto.User;
rule "validate_user"
when
userX : User(getName().equals("test123"))
then
userX.setDescription("changed in workflow)";
System.out.println("user is test123");
end
--------
The editor does not flag any errors, but, when I run the workflow through my
webapp, I see the following error :
Rule Compilation error : [Rule name='validate_user']
com/x/workflow/Rule_validate_user.java (7:439) : Syntax error, insert ")"
to complete Expression
904224 [tomcat-http--51] ERROR
org.activiti.engine.impl.interceptor.CommandContext - Error while closing
command context
java.lang.IllegalArgumentException: Could not parse knowledge.
at
org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67)
at
org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:61)
the java file Rule_validate_user.java is not written by me, in fact I cannot
locate it in my source.
It appears it is generated by drools engine.
And, I cannot find what is wrong with my drl file from the error printed.
Appreciate any pointers.
thanks
sapra
--
View this message in context: http://drools.46999.n3.nabble.com/discrepency-between-drools-eclipse-edit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
Problem with DroolsFlow transaction
by HMandic
I have a problem with transaction manager in drools flow (at least I think
so).
I'm running an EJB3 application in Jboss AS 5.1.0GA with Postgres 8.4.4 as
database. I use one schema for my data and another for drools data. The
application itself is also split in two projects, one for my utility classes
that interact with drools and the other for my application that uses those
utility classes.
I'm using the same datasource and transaction type is JTA.
I have an object that holds a reference to processID from drools flow as one
of its fields. When I invoke my method to create that object (in a stateless
session bean), a transaction is opened and it lasts until the end of said
method. But somewhere inside that method I need to invoke
ksession.startProcess(processName, params) and then I get this:
java.lang.IllegalStateException: Wrong tx on thread: expected
TransactionImple < ac, BasicAction: -3f57ffd6:dfb:4c878d37:7e status:
ActionStatus.ABORTED >, actual null
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:157)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
.
.
.
Does that mean that I need to run the drools part in a separate thread?
I'm clueless...
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-DroolsFl...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Date comparison
by Deshpande, Prasad
Hi,
As per documentation, I'm trying to use a simple rule for date comparison,
rule "EFP_14"
when
v:ResourceValue(QName == "A.datetime", value > "01-nov-2011")
then
System.out.println("--> Rule executed");
end
but I get following error while executing rule.
Not possible to compare a class java.util.Date with a class java.lang.String
It's actually default date format so should work, why is it complaining for class casting? Am I doing something wrong here?
________________________________
BancTec Limited.
Registered Office: Jarman House, Mathisen Way, Poyle Road, Colnbrook, Berkshire SL3 0HF. Incorporated in England & Wales : 1283512. VAT : GB 228 4783 38.
14 years, 2 months