1 Reply Latest reply on Jun 30, 2011 8:57 AM by Bruce Cui

    Is there a way to make ksession aware service task running in web console?

    Bruce Cui Newbie



      I open this new thread to draw some attention. I'm looking for a solution to drive batch processes by jBPM5. Since I'm new to it, I have fought with various problems and finally made some progress by deeper study and help from the forum, especially from Kris.


      Currenly I'm stuck at one key problem. I want to put a time consuming task in the main progress. But I found that once such a progress started from web console, it would not be able for other processes to make any movement. It seems that the console is running all processes in one main thread.


      So I tried to pass the processInstance as a parameter from the process to the WorkItemHandler at runtime. And the WorkItemHandler will start a new thread of an object which contains the actual logic in its run() method. Once the thread is done, at the end of its run() method, it sends the signal back via the reference of the processInstance.


      Local running was fine, but once I put it up to console war and tried to start the process from console, I got IOException due to WorkItem persistance problem.


      Kris gave me another advice, that to pass the ksession to the WorkItemHandler when registering it. But a problem is, the pattern of how the console create the WorkItemHandlers are already there in the console code. I don't know how to make the console recognize and pass the kession automatically without changing any code.


      Can anyone help to advise if there is an elegant way to make a service task both ksession aware, and also can work in console environment? If there is none, is it possible to change the code to make this happen, and how? Thanks in advance.

        • 1. Re: Is there a way to make ksession aware service task running in web console?
          Bruce Cui Newbie

          Here are some of my findings:


          The exception is threw out by the WorkItemInfo class's update method. From there I found that the code is trying to marshal the parameter map. And the marshal strategies are set in the EnvironmentImpl object when EnvironmentFactory instantiats the instance. The only currently used strategy is a serialize strategy, which requires all objects implements java.io.Serializable interface, which is not by either the StatefulKnowledgeSessionImpl class, or the ProcessRuntimeImpl class. Therefore, it threw out IOException while trying to serialize them into stream.


          I'm thinking, if I put one strategy before the serialize strategy, which only accept StatefulKnowledgeSessionImpl or some high level interface, and it doesn't perform serialization, it might be able to avoid this exception.


          I found that there are some other strategies, such like IdentityPlaceholderResolverStrategy, defined in the  the MarshallerProvider. But the actually used marshal strategy is hardcoded in the EnvironmentFactory. I'm wondering if there is a way to change the strategy array in a declarative way, or I have to change some code to make this happen?