I don't really know whether your rule will be activated or not, but you are missing the ksession.fireAllRules() call. Try to add a Logger to your session to see if the rule gets activated or not.<div><br></div><div>Best, <br>
<br><div class="gmail_quote">2010/5/19 HONG DENG <span dir="ltr"><<a href="mailto:denghongster@gmail.com">denghongster@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<b><font color="#FF0000">I paste all information here :<br><br>HelloWorldSample.rf </font></b> :<br><br><?xml version="1.0" encoding="UTF-8"?> <br><process xmlns="<a href="http://drools.org/drools-5.0/process" target="_blank">http://drools.org/drools-5.0/process</a>"<br>
xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>"<br> xs:schemaLocation="<a href="http://drools.org/drools-5.0/process" target="_blank">http://drools.org/drools-5.0/process</a> drools-processes-5.0.xsd"<br>
type="RuleFlow" name="flow" id="com.sample.evaluation" package-name="org.drools.bpmn2" ><br><br> <header><br> </header><br><br> <nodes><br> <start id="1" name="Start" x="44" y="139" width="48" height="48" /><br>
<humanTask id="2" name="thefirstone" x="156" y="140" width="80" height="40" ><br> <work name="Human Task" ><br> <parameter name="ActorId" ><br>
<type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br> <value></value><br> </parameter><br> <parameter name="Comment" ><br>
<type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br> <value>You need to perform a self-evaluation</value><br> </parameter><br> <parameter name="Content" ><br>
<type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br> </parameter><br> <parameter name="Priority" ><br> <type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br>
</parameter><br> <parameter name="Skippable" ><br> <type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br> <value>false</value><br>
</parameter><br> <parameter name="TaskName" ><br> <type name="org.drools.process.core.datatype.impl.type.StringDataType" /><br> <value>firstHumanTask</value><br>
</parameter><br> </work><br> </humanTask><br> <end id="3" name="End" x="290" y="140" width="80" height="40" /><br> </nodes><br>
<br> <connections><br> <connection from="1" to="2" /><br> <connection from="2" to="3" /><br> </connections><br><br></process><br><br><font color="#FF0000"><b>assignment.dslr:</b></font><br>
package org.drools.examples.process.order<br><br>import org.drools.process.instance.impl.WorkItemImpl<br>import org.drools.workflow.instance.node.WorkItemNodeInstance<br><br>expander assignment.dsl<br><br>/********** Generic assignment rules **********/<br>
<br>rule "Assign actor" salience 30<br>        when<br> There is a human task<br>        then <div> Set actor id "mary"<br>end</div><div><br></div><div><br></div><div><div><b><font color="#FF0000">assignment.dsl:</font></b></div>
<div><b></b><font color="#FF0000"><b><div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]- with actor id "{actorId}"=parameters['ActorId'] == "{actorId}"</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]- without actor id=parameters['ActorId'] == null</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]- with task name "{taskName}"=parameters['TaskName'] == "{taskName}"</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]There is a human task=workItemNodeInstance: WorkItemNodeInstance( ) workItem: WorkItemImpl( name == "Human Task" ) from workItemNodeInstance.workItem</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[consequence][]Set actor id "{actorId}"=workItem.setParameter("ActorId", "{actorId}"); update(workItemNodeInstance);</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]- with priority {priority}=parameters['Priority'] == {priority}</span></font></span></div>
<div><span style="font-weight:normal"><font color="#000000"><span style="font-size:x-small">[condition][HumanTaskWorkItem]Process "{processId}" contains a human task=workItemNodeInstance: WorkItemNodeInstance( processInstance.processId == "{processId}" ) workItem: WorkItemImpl( name == "Human Task" ) from workItemNodeInstance.workItem</span></font></span></div>
</b></font></div><br><b><font color="#FF0000">and have following code to start a process instance:</font></b></div><div><b><font color="#FF0000"><div><font color="#000000"><span style="font-weight:normal">package com.sample;</span></font></div>
<div><font color="#000000"><span style="font-weight:normal">/**</span></font></div><div><font color="#000000"><span style="font-weight:normal"> * This is a sample file to launch a process.</span></font></div>
<div><font color="#000000"><span style="font-weight:normal"> */</span></font></div><div><font color="#000000"><span style="font-weight:normal">public class ProcessTest {</span></font></div>
<div><font color="#000000"><span style="font-weight:normal"><br></span></font></div><div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">public static final void main(String[] args) {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">try {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">//start humantask component</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">startHumanTaskComponent();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">// load up the knowledge base</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">KnowledgeBase kbase = readKnowledgeBase();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">// start a new process instance</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">Map<String, Object> params = new HashMap<String, Object>();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">params.put("employee", "Administrator");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">ksession.startProcess("com.sample.evaluation", params);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">} catch (Throwable t) {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                        </span></font></span><font color="#000000"><span style="font-weight:normal">t.printStackTrace();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">}</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">}</span></font></div>
<div><font color="#000000"><span style="font-weight:normal"><br></span></font></div><div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">private static KnowledgeBase readKnowledgeBase() throws Exception {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();</span></font></div>
<div><font color="#000000"><span style="font-weight:normal">//</span></font><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> ((PackageBuilderConfiguration) conf).initSemanticModules();</span></font></div>
<div><font color="#000000"><span style="font-weight:normal">//</span></font><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> ((PackageBuilderConfiguration) conf).loadSemanticModule("BPMN2SemanticModule.conf");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(conf);</span></font></div>
<div><font color="#000000"><span style="font-weight:normal">//</span></font><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> kbuilder.add(ResourceFactory.newClassPathResource("hellowWorld.bpmn"), ResourceType.DRF);</span></font></div>
<div class="im">
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> kbuilder.add(ResourceFactory.newClassPathResource("HelloWorldSample.rf"), ResourceType.DRF);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dsl"), ResourceType.DSL);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dslr"), ResourceType.DSLR);</span></font></div>
</div><div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> KnowledgeBuilderErrors errors = kbuilder.getErrors();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> if (errors.size() > 0) {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> for (KnowledgeBuilderError error: errors) {</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> System.err.println(error);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> }</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> throw new IllegalArgumentException("Could not parse knowledge.");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> }</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal"> return kbase;</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">}</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span></div><div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">private static void startHumanTaskComponent(){</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.task");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">TaskService taskService = new TaskService(emf,SystemEventListenerFactory.getSystemEventListener());</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">User a = new User("john");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">User b = new User("mary");</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">TaskServiceSession taskSession = taskService.createSession(); </span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">taskSession.addUser(new User("Administrator"));</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">taskSession.addUser(a);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">taskSession.addUser(b);</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">MinaTaskServer server = new MinaTaskServer( taskService );</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">Thread thread = new Thread( server );</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">                </span></font></span><font color="#000000"><span style="font-weight:normal">thread.start();</span></font></div>
<div><span style="white-space:pre"><font color="#000000"><span style="font-weight:normal">        </span></font></span><font color="#000000"><span style="font-weight:normal">}</span></font></div>
<div><font color="#000000"><span style="font-weight:normal"><br></span></font></div><div><font color="#000000"><span style="font-weight:normal">}</span></font></div>
</font></b></div><div><br><br>2010/5/19 Esteban Aliverti <<a href="mailto:esteban.aliverti@gmail.com" target="_blank">esteban.aliverti@gmail.com</a>>:<div><div></div><div class="h5"><br>> A good start could be to give us more info, like your rules, your flow and<br>
> how are you executing them. ;)<br>> Best,<br>><br>> On Wed, May 19, 2010 at 6:39 AM, HONG DENG <<a href="mailto:denghongster@gmail.com" target="_blank">denghongster@gmail.com</a>> wrote:<br>>><br>
>> hi , i am a drools flow newbie.I want to using "assignment rule"<br>
>> assign a actor to a HumanTask. I have write a dsl and dslr files and<br>>> following code :<br>>><br>>> <br>>> kbuilder.add(ResourceFactory.newClassPathResource("HelloWorldSample.rf"),<br>
>> ResourceType.DRF);<br>>> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dsl"),<br>>> ResourceType.DSL);<br>>> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dslr"),<br>
>> ResourceType.DSLR);<br>>><br>>> but when i start a process instance and the token arrive at a<br>>> humantask,the "assignment rule" couldn't be firing.<br>>> who can tell me how can i do it?<br>
>> _______________________________________________<br>>> rules-users mailing list<br>>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>><br>><br>> --<br>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>><br>> Esteban Aliverti<br>><br>> _______________________________________________<br>> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>><br>><br><br></div></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>
</div>