[jBPM] - ReceiveTaskHandler handling multiple process intances with the same message-id
by Melih Cetin
Melih Cetin [http://community.jboss.org/people/mscetin] created the discussion
"ReceiveTaskHandler handling multiple process intances with the same message-id"
To view the discussion, visit: http://community.jboss.org/message/617949#617949
--------------------------------------------------------------
BPMN2 JUnit test for BPMN2-ReceiveTask is implemented as
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
...
receiveTaskHandler.messageReceived("HelloMessage", "Hello john!");
I tried to use ReceiveTaskHandler class in a project to receive a notification from an external system for a specific process-instance and resume the process upon receipt of the message. I could not figure out how to specify the process-instance for which the received message is applicable.
JUinit test works fine as there is only one process instance in the session during the execution of this test. The source code for ReceiveTaskHandler is:
public class ReceiveTaskHandler implements WorkItemHandler {
// TODO: use correlation instead of message id
private Map<String, Long> waiting = new HashMap<String, Long>();
...
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
String messageId = (String) workItem.getParameter("MessageId");
waiting.put(messageId, workItem.getId());
* // If waiting map previously contained a mapping for messageId, the old value is replaced !!!*
}
public void messageReceived(String messageId, Object message) {
Long workItemId = waiting.get(messageId);
if (workItemId == null) {
return;
}
Map<String, Object> results = new HashMap<String, Object>();
results.put("Message", message);
ksession.getWorkItemManager().completeWorkItem(workItemId, results);
}
...
}
The comment of // TODO: use correlation instead of message id at the top of the source file also gave the impression that the implementation is not complete. As an interim solution, I decided to extend ReceiveTaskHandler class as follows:
public class ReceiveTaskHandler extends org.jbpm.bpmn2.handler.ReceiveTaskHandler {
private Map<String, Long> waiting = new HashMap<String, Long>();
private KnowledgeRuntime ksession;
public ReceiveTaskHandler(KnowledgeRuntime ksession) {
super(ksession);
this.ksession = ksession;
}
private String constructKey(long processInstanceId, String messageId) {
return processInstanceId + "|" + messageId;
}
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
long processInstanceId = workItem.getProcessInstanceId();
String messageId = (String) workItem.getParameter("MessageId");
waiting.put(constructKey(processInstanceId, messageId), workItem.getId());
// If waiting map previously contained a mapping for messageId, the old value is replaced !!!
}
@Override
public void messageReceived(String messageId, Object message) {
throw new UnsupportedOperationException(
"messageReceived(String messageId, Object message) method is not supported. " +
"Instead use messageReceived(long, String, Object) method" );
}
public void messageReceived(long processInstanceId, String messageId, Object message) {
Long workItemId = waiting.get(constructKey(processInstanceId, messageId));
if (workItemId == null) {
return;
}
Map<String, Object> results = new HashMap<String, Object>();
results.put("Message", message);
ksession.getWorkItemManager().completeWorkItem(workItemId, results);
}
}
I was wondering if "Receive Task" is the right task to use for waiting an external notification. If yes, then can any core jBPM contributor review the extension that I used locally and consider adding it to the next release of jBPM.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/617949#617949]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
12 years, 7 months
[jBPM] - problem about jbpm5.1 web console
by HUI LIU
HUI LIU [http://community.jboss.org/people/brianlh] created the discussion
"problem about jbpm5.1 web console"
To view the discussion, visit: http://community.jboss.org/message/614794#614794
--------------------------------------------------------------
I have installed jbpm5.1 by "ant install.demo" and started it.
When I access jbpm5.1.0 web console http://localhost:8080/jbpm-console/app.htm http://localhost:8080/jbpm-console/app.htm and review the process list,
then an exception is thrown out.
Who can give me some advice to solve the problem?
Thanks in advance.
=========================================
URL: 'http://localhost:8080/gwt-console-server/rs/process/definitions' Action: 'org.jboss.bpm.console.client.process.UpdateDefinitionsAction' Exception: 'class com.google.gwt.http.client.RequestException' HTTP 500: Etat HTTP 500 - type Rapport d'exception message description Le serveur a rencontr� une erreur interne () qui l'a emp�ch� de satisfaire la requ�te. exception org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: Failed to load: org.jbpm.integration.console.ManagementFactoryImpl org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:319) org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:230) org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:206) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:360) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)=========================================
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/614794#614794]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
12 years, 7 months
[EJB3] - EJB3 Session Bean Pool
by Robert Geisler
Robert Geisler [http://community.jboss.org/people/robert.geisler] created the discussion
"EJB3 Session Bean Pool"
To view the discussion, visit: http://community.jboss.org/message/597611#597611
--------------------------------------------------------------
hello...
during the last few weeks we experienced some problems with session bean instantiation.
in the past we used default session bean pool, ThreadlocalPool. this pool implementation creates instances for every newly created thread, but these instances seem to never be destroyed, not even if the threads, they were created for, die.
so we tried StrictMaxPool pool implementation and set a maximum of 100.000. with this pool we see much less bean instances, because the pool creates them only if there are no free instances left. existing beans (released earlier) get reused later, allthough they are not destroyed until container/ server shuts down.
a simple scenario: in the morning 200 users log in and read their private messages. they all start working at 8 a.m. and they are using mostly the same services. every single user needs one bean instance for one request and because all users request concurrently, StrictMaxPool creates 200 instances. later the users have lunch, so no one fires request to the server, all beans (200!) are released and waiting in the pool. but because StrictMaxPool does not destroy beans, the 200 instances are kept in server vm/ heap all the day (until shutdown!).
we think this behaviour is a waste of resources! a pool should destroy instances if there a more instances in the pool than we want to reserve for further usage. because later the day our 200 users will almost never produce 200 concurrent requests again, we would like to configure the pool to just keep a maximum of 50 beans.
so my questions are:
1) why are instances not destroyed by StrictMaxPool? there is an idea of destroying instances in StrictMaxPool.release, but because pool.size will never be more than maxSize (an attemp to get one more bean always fails!), remove is never called!?
2) is there a pool implementation that destroys instances and just holds a configurable amount of beans? or do we have to implement it on our own (TolerantMinPool ; ))?
3) ?some more suggestions?
thanks in advance
robert
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/597611#597611]
Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
12 years, 7 months
[jBPM] - jBPM5 - Using as a state machine in clustered spring application with a dashboard
by Narayan Singh
Narayan Singh [http://community.jboss.org/people/narayans] created the discussion
"jBPM5 - Using as a state machine in clustered spring application with a dashboard"
To view the discussion, visit: http://community.jboss.org/message/595120#595120
--------------------------------------------------------------
We're currently investigating to use BPM as a workflow/state machine for process orchestration in a very high volume clustered environment. Orchestration component is Spring application which sends and receives events from other component over MQ/REST and basically events decides process state transition.
Here are some basic requirements for the Orchestration component we have and so far my observations with jBPM5 -
1. Clustering and Server deployment - Multiple instances of orchestration component are deployed to the cluster, hence the process state is maintained across cluster and server instances can drop and join the cluster any time.
Observation: If I use drools-spring to boot-strap my jBPM5 engine then I got 2 options - a) create new session or b) load existing session. But to load existing session I need to specify session id. In other words, I would need to write custom code upfront to decide whether I want to create new session or load existing one based on some thing, and this code needs to be cluster-safe as multiple instances starting up at the same time.
So do you agree we cant use any out-of-the box solution here and one have to write custom boot-strap code?
2. Dashboard support - We have our own platform-wide Dashboard and we want to add process state information to it, ideally using REST interface provided by jBPM. So we're not using any of jBPM console apps provided out-of-the-box.
Observation: currently jBPM console functionality is consists of JBoss BPM modules(ex. org.jboss.bpm:gwt-console-server etc) hooked in with jBPM integration services as provided in jbpm-gwt-xxx modules. we cant use it out-of-the box because -
1/ some of the jbpm-gwt-xxx modules have got persistence.xml with hard-wired H2 database details
2/ they are tightly coupled with Human-task and Guvonor, however in our case we are bundling all our processes as part of the application and not using any WS-HT either. In other words state transition of our process is driven by the events.
So as I understand we would need to build our version of "org.jboss.bpm:gwt-console-server" bundled with custom services to expose REST api to be used by dashboard. Would Knowledge api be used to extract current state from the database or am I missing something here?
3. Persistence - As I understand there are 2 forms of it - runtime state and auditing. Auditing is mainly pluggable using various listeners, and there are some out-of the box audit loggers available. For Runtime state, which is core part of jBPM5, I only see 3 entities -
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
Observation: Runtime state is stored in binary form and there is no relationship between tables, so merely looking at tables not able to say which process part of which session. So one has to use knowledgeSession to extract the information.
I see loads of potential in jBPM5 and believe it could be used in our case. I would really appreciate any directions here to understand how it can solve our requirements as pointed out above?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/595120#595120]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
12 years, 7 months
[jBPM] - Incorrect Gateway diverge and converge operations in jBPM 5
by shashi mhatre
shashi mhatre [http://community.jboss.org/people/khalipili] created the discussion
"Incorrect Gateway diverge and converge operations in jBPM 5"
To view the discussion, visit: http://community.jboss.org/message/581930#581930
--------------------------------------------------------------
I am using below sample flow in my test. it contains three human task. once the process process is started it execute successfully till human task creation. As the first gateway diverge is of type "AND" it creates two task as shown below. I can view these task in jbpm-console. now once i login as user "Shashi" and complete the first task, As the next gateway converge is of type "XOR", the flow proceeds further and create the next task for user "Shashi".
As process have proceed further till gateway converge, jbpm should have remove the task for user "kris". but jbpm still shows the task for user "kris".
this seems to be a error in jbpm process execution.
next once user "shashi" completes the human task, process execution completes but throws below error. it seems that human task handler tries to abort the "kris" task which should have be aborted prior (at gateway converge).
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: attempt to create merge event with null entity
at org.hibernate.event.MergeEvent.<init>(MergeEvent.java:60)
at org.hibernate.event.MergeEvent.<init>(MergeEvent.java:43)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:235)
at org.drools.persistence.processinstance.JPAWorkItemManager.abortWorkItem(JPAWorkItemManager.java:124)
at org.drools.command.runtime.process.AbortWorkItemCommand.execute(AbortWorkItemCommand.java:56)
at org.drools.command.runtime.process.AbortWorkItemCommand.execute(AbortWorkItemCommand.java:29)
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:274)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.abortWorkItem(CommandBasedStatefulKnowledgeSession.java:149)
at com.sample.util.CommandBasedWSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(CommandBasedWSHumanTaskHandler.java:257)
at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:81)
at org.jbpm.task.service.mina.MinaTaskClientHandler.messageReceived(MinaTaskClientHandler.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
[2011:01:19 17:01:78:exception] Uncaught exception on client
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
. http://community.jboss.org/servlet/JiveServlet/showImage/2-581930-11171/S... http://community.jboss.org/servlet/JiveServlet/downloadImage/2-581930-111...
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/581930#581930]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
12 years, 8 months