StatefulKnowledgeSessions
by alim
Hi everyone,
I'm trying to find a solution to the following situation:
- KnowledgeBase with approx. 1000 rules
- Approx. 200 users (hence 200 simultaneous sessions) whereas each session
might most likely have different values for the working memory facts
So let's say we create a KnowledgeBase (with those 1000 rules) and out of
this one KnowledgeBase we create for each existing session its own
StatefulKnowledgeSession.
Now, how expensive (memory-wise) are these StatefulKnowledgeSessions? Is it
reasonable to have more than just a few StatefulKnowledgeSessions?
Or is there an other, better approach?
Thank you very much!
--
View this message in context: http://n3.nabble.com/StatefulKnowledgeSessions-tp688305p688305.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
java.io.EOFException when trying Drools rulefow Evaluation example
by laurence vignollet
I am starting with Drools.
I am using Drools Flow 5.0.1, Eclipse 5.2, JDK 1.6.0.
I am trying to run the Evaluation Example. It has just 3 human tasks. I
launched a Mina task Server that seems to work fine. Error occurs on the
server when launching the ruflow that is trying to add the task to the
server.
[10:01:12] NioProcessor-1 INFO [] []
[org.apache.mina.filter.logging.LoggingFilter] - CREATED
[10:01:12] NioProcessor-1 INFO [] []
[org.apache.mina.filter.logging.LoggingFilter] - OPENED
[10:01:12] NioProcessor-1 INFO [] []
[org.apache.mina.filter.logging.LoggingFilter] - RECEIVED: HeapBuffer[pos=0
lim=404 cap=2048: 00 00 01 90 AC ED 00 05 73 72 01 00 1F 6F 72 67...]
[2010:04:91 10:04:60:exception] Uncaught exception on Server
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.core.buffer.BufferDataException: java.io.EOFException
(Hexdump: 00 00 01 90 AC ED 00 05 73 72 01 00 1F 6F 72 67 2E 64 72 6F 6F 6C
73 2E 74 61 73 6B 2E 73 65 72 76 69 63 65 2E 43 6F 6D 6D 61 6E 64 78 70 00
00 00 00 73 72 01 00 13 6A 61 76 61 2E 75 74 69 6C 2E 41 72 72 61 79 4C 69
73 74 78 70 00 00 00 02 77 04 00 00 00 02 73 72 01 00 14 6F 72 67 2E 64 72
6F 6F 6C 73 2E 74 61 73 6B 2E 54 61 73 6B 78 70 77 D0 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 05 65 6E 2D 55 4B 00
0A 45 76 61 6C 75 61 74 69 6F 6E 00 00 00 01 00 00 00 00 00 00 00 00 00 05
65 6E 2D 55 4B 00 0F 53 65 6C 66 20 45 76 61 6C 75 61 74 69 6F 6E 00 00 00
01 00 00 00 00 00 00 00 00 00 05 65 6E 2D 55 4B 00 0F 53 65 6C 66 20 45 76
61 6C 75 61 74 69 6F 6E 01 00 00 00 00 01 00 00 00 03 66 72 61 00 00 00 00
00 00 00 00 00 00 00 01 00 00 00 0D 41 64 6D 69 6E 69 73 74 72 61 74 6F 72
00 00 00 00 00 01 01 00 07 43 72 65 61 74 65 64 00 00 00 00 00 00 00 01 00
00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 70 78 7E 72 01 00 23 6F 72 67 2E 64 72 6F 6F 6C 73 2E 74 61 73 6B 2E
73 65 72 76 69 63 65 2E 43 6F 6D 6D 61 6E 64 4E 61 6D 65 78 72 01 00 0E 6A
61 76 61 2E 6C 61 6E 67 2E 45 6E 75 6D 78 70 74 00 0E 41 64 64 54 61 73 6B
52 65 71 75 65 73 74)
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:180)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:95)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.mina.core.buffer.BufferDataException:
java.io.EOFException
at
org.apache.mina.core.buffer.AbstractIoBuffer.getObject(AbstractIoBuffer.java:1630)
at
org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:93)
at
org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:173)
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:170)
... 19 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.readBoolean(Unknown
Source)
at java.io <http://java.io.objectinputstream.re/>.ObjectInputStream.readBoolean(Unknown
Source)
at org.drools.task.Task.readExternal(Task.java:139)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.ArrayList.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io <http://java.io.objectstreamclass.in/>.ObjectStreamClass.invokeReadObject(Unknown
Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io <http://java.io.objectinputstream.de/>.ObjectInputStream.defaultReadFields(Unknown
Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at
org.apache.mina.core.buffer.AbstractIoBuffer.getObject(AbstractIoBuffer.java:1628)
... 22 more
The Server Code is:
import org.drools.SystemEventListenerFactory;
import org.drools.task.Task;
import org.drools.task.User;
import org.drools.task.service.ContentData;
import org.drools.task.service.MinaTaskServer;
import org.drools.task.service.TaskService;
import org.drools.task.service.TaskServiceSession;
public class Server {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.task");
TaskService taskService = new TaskService(emf,
SystemEventListenerFactory.getSystemEventListener());
TaskServiceSession taskSession = taskService.createSession();
//Ajouter user.
taskSession.addUser(new User("Mary"));
taskSession.addUser(new User("John"));
taskSession.addUser(new User("fra"));
MinaTaskServer server = new MinaTaskServer( taskService );
Thread thread = new Thread( server );
thread.start();
}
}
And the Process part is:
package com.sample;
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io <http://org.drools.io.re/>.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.process.workitem.wsht.WSHumanTaskHandler;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessInstance;
/**
* This is a sample file to launch a process.
*/
public class RuleFlowTest {
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");
//NEW
ksession.getWorkItemManager().registerWorkItemHandler("Human
Task", new WSHumanTaskHandler());
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee","fra");
// end NEW
// start a new process instance
ProcessInstance processInstance =
ksession.startProcess("com.sample.ruleflow",params); //modificat params
ksession.insert(processInstance);
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}java.io.EOFException when trying Drools rulefow Evaluation example
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"),
ResourceType.DRF);
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();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
Thankyou in advance a lot for you help.
14 years, 9 months