5 Replies Latest reply on Apr 2, 2012 8:35 AM by melc

    Process output : Is there a way to get output from a process

    lakshmi.sampath

      Hi,

       

      I need to get an output variable from a process. Is there a way to do it similar to providing input while starting a process.

       

       

      ksession.startProcess(processName,parameterMap);

      The return type of above call is ProcessInstance which only tells you the return state like ACTIVE, COMPLETED etc, but I would like to get an output object similar to input parameterMap.  One way to do is to use custom tables to save the data from inside the process but I want to get that information back from the process instead of using my own cutom tables.

      thanks

      lakshmi.

        • 1. Re: Process output : Is there a way to get output from a process
          nt2005

          Hello Lakshmi,

           

          I do somthing like that and for me it works good:

           

          Start the process with a own handler:

          GuiProcessHandler handler = new GuiProcessHandler();

          Map<String, Object> params = new HashMap<String, Object>();

          params.put("handler", handler);

                 

          // start a new process instance

          ksession.startProcess(processName, params);

           

          ...handler.getOutputs();

           

          A workitem for imageoutput:

          public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {    

             BufferedImage image ...

             GuiProcessHandler handler = (GuiProcessHandler) workItem.getParameter("handler");

             handler.addImage(image);

          }

           

          Please note BufferedImage is not serializable, so you must convert it to a byte array.

           

          Good luck!

          • 2. Re: Process output : Is there a way to get output from a process
            melc

            Hi,

            You should make the process call a web service of your system, or some other means of communication i.e. ejb, jms etc.  This can be easily implemented within a work item.

            Another approach could be to pass an object to the process which allows to add a listener to it and then make the process to trigger the event, when it reaches the desired state. In more detail, you add a listener from your system to that object, pass the object as input parameter to the process and the process triggers the event that in turn will call all the listeners registered to the object i.e. one of them should be a listener of your system.

            1 of 1 people found this helpful
            • 3. Re: Process output : Is there a way to get output from a process
              lakshmi.sampath

              Thanks nt2005 and Chris. I agree, listener object passed as input to process is probably the better way to get the output.  I think JBPM dev team should consider providing a output paramter map as inbuilt support since I think expecting output from a process would be a very basic requirement. Just getting the status of process as ACTIVE/COMPLETED/etc is not enough.

               

              thanks

              lakshmi.

              • 4. Re: Process output : Is there a way to get output from a process
                lakshmi.sampath

                The above mentiond approach worked for listening to the output when a process is running. Apart from that I had to suspend the process  and later call stop on the process. Now I couldn't get the output from a stop. I resolved it by creating a static class that holds a hash map of process id as key and output as object value. When a process is stopped, the service work item handler abort method writes the output to the static class hash map and later its available to the thread invoking the stop.

                 

                I wished start and stop process both gave the output back(JBPM Dev Team - If you are listening to this, please let me know why this feature is not implemented?)

                 

                thanks

                lakshmi.

                • 5. Re: Process output : Is there a way to get output from a process
                  melc

                  Hi,

                  You can simply add a ProcessEventListener and have access to variables at any stage of the process.