[jboss-user] [jBPM] - Diagram not upadet (using async. work item)

Livia Hauser do-not-reply at jboss.com
Tue Oct 4 07:11:00 EDT 2011


Livia Hauser [http://community.jboss.org/people/liviah] created the discussion

"Diagram not upadet (using async. work item)"

To view the discussion, visit: http://community.jboss.org/message/630012#630012

--------------------------------------------------------------
Hi All,

last weekend I played arround with drools (5.3.0.CR1) and  jbpm (5.1.1.Final) on jboss 5.1.
I have a simple bpmn:
[1]start -> [2] timer ->[3]script -> [4]AsyncHandler -> [5]timer -> [6]script -> [7]end

After my AsyncHandler calls completeWorkItem task [5] and [6] will executed. But if I take a look at the diagram task [4] is still highlighted.

How I can make shure a user will see right/updated diagram?

My WorkHandler to test a asynch behavior:

public class AsyncWorkItemHandler implements WorkItemHandler {

     StatefulKnowledgeSession ksession;


    public AsyncWorkItemHandler(ProcessContext kcontext){
        super();
        this.ksession = (StatefulKnowledgeSession)kcontext.getKnowledgeRuntime();
    }

    public AsyncWorkItemHandler(StatefulKnowledgeSession ksession) {
        super();
        this.ksession = ksession;

   @Override
   public void executeWorkItem(WorkItem workItem, WorkItemManager manager){

        class WThread extends Thread{

            int sessionId;
            long itemId;
            KnowledgeBase kbase;
            Environment env;

            public WThread(int sessionId,  long itemId,
                    KnowledgeBase kbase, Environment env) {
                super();
                this.sessionId = sessionId;;
                this.itemId = itemId;
                this.kbase = kbase;
                this.env = env;
            }

            @Override
            public void run(){
                int seconds = 30;
                System.out.println("thread for session " + this.sessionId + " (workitem "+ this.itemId +"), sleep " + seconds + "s");
                try {
                    Thread.currentThread().sleep(seconds * 1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(this.sessionId, kbase, null, env);
                ksession.getWorkItemManager().registerWorkItemHandler("AsyncTask", new AsyncWorkItemHandler(ksession));
                ksession.getWorkItemManager().completeWorkItem(this.itemId, null);
                System.out.println("thread for session " + this.sessionId + " (workitem "+ this.itemId +") end");

                this.clean();

            }

               protected void clean(){
                   this.kbase = null;
                   this.env = null;
            }
        }

        KnowledgeBase kbase = ksession.getKnowledgeBase();
        Environment env = ksession.getEnvironment();
        int sessionId = ksession.getId();
        long itemId = workItem.getId();
        WThread t = new WThread(sessionId, /*processId,*/ itemId, kbase, env);
        t.start();
      }

    }

}


Any hints?

Many thx + greetings,
Livia
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/630012#630012]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111004/5f40ad08/attachment.html 


More information about the jboss-user mailing list