Hello there,
I am experimenting with Drools. I seem to be having problems with making
the ForEach element to work. It cannot 'see' the mappings created when I
start the process. I am hand coding the XML flow files and using the
schema (and documentation) to help me.
The problem seems to be in the flow file before the rule file is even
executed. Is this the correct way to pass a collection to the process?
// the collection to iterate over
Collection<BusinessObject> pending = new ArrayList<BusinessObject>();
pending.add(new BusinessObject());
pending.add(new BusinessObject());
// the parameters for the process
Map<String, Object> params = new HashMap<String, Object>();
params.put("pending", pending);
ksession.startProcess("org.processor", params);
ksession.fireAllRules();
In the rule file, I have:
<forEach id="2" name="processor"
variableName="current"
collectionExpression="pending" >
<in-ports>
<in-port type="DROOLS_DEFAULT" nodeId="6"
nodeInType="DROOLS_DEFAULT" />
</in-ports>
<out-ports>
<out-port type="DROOLS_DEFAULT" nodeId="8"
nodeOutType="DROOLS_DEFAULT" />
</out-ports>
<nodes>
<start id="6" name="test" />
<actionNode id="7">
<action type="expression" dialect="mvel">
System.out.println(current);
</action>
</actionNode>
<end id="8" name="done"/>
</nodes>
<connections>
<connection from="6" to="7" />
<connection from="7" to="8" />
</connections>
</forEach>
I cannot tell if the scope inside the ForEach > nodes is separate from the
outer-scope, can I use the same IDs?
The error I receive:
Exception in thread "main" java.lang.IllegalArgumentException: Could not
find collection params
What am I doing wrong?
Regards,
S. Squire
This message may contain confidential and privileged information and is intended solely
for the use of the named addressee. Access, copying or re-use of the e-mail or any
information contained therein by any other person is not authorised. If you are not the
intended recipient please notify us immediately by returning the e-mail to the originator
and then immediately delete this message. Although we attempt to sweep e-mail and
attachments for viruses, we do not guarantee that either are virus-free and accept no
liability for any damage sustained as a result of viruses.
Please refer to
http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.