6 Replies Latest reply on Jul 20, 2011 8:15 AM by olddave

    How to retrieve parameters after Process finish

    olddave Newbie

      Hi,

       

      I have a BPMN2 Process which deals with a single Java object with several fields. It is called for up to millions of records, once for each object. Very occasionally (a few dozen times out of a million objects) a Human Task is invoked and the user will alter a couple of the field values. How do I retrieve these after each Process has completed?  I looked at the test cases and never found one that retrieved any of the passe din parameters after the Process had run.

       

      In addition is there a recommended approach to running the same Process millions of times, for performance optimization?

       

      Thx.

       

      Ed

        • 1. Re: How to retrieve parameters after Process finish
          Demian Calcaprina Master

          You can use a JPAWorkingMemoryDbLogger to save information in audit tables while executing, and then use JPAProcessInstanceDbLog which receives the environment, to use findVariableInstances(processInstanceId), that will give you all the variables of this processInstance.

           

          Demian

          1 of 1 people found this helpful
          • 2. Re: How to retrieve parameters after Process finish
            olddave Newbie

            That seems convoluted? Doesn't something like this work?

             

            [code]

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

                TransformData tData = new TransformData();

                tData.setValues(transform);

                params.put("transformData", tData);

                org.drools.runtime.process.ProcessInstance pInst = ksession.startProcess(transformationWorkflow.getUuid().toString().substring(1), params);

                tData = (TransformData) ksession.getEnvironment().get("transformData");

             

            [/code]

            • 3. Re: How to retrieve parameters after Process finish
              Demian Calcaprina Master

              Are you using persistence? If so, I think the process is deleted from session, and you have to use the audit tables.

              http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2836

               

              If you are not using persistence, I think you could get the ProcessInstance instance before it finishes, and then get the variable:

              WorkflowProcessInstance pi = (WorkflowProcessInstance)session.getProcessInstance(processInstanceId);

              ...

              pi.getVariable("var")

              1 of 1 people found this helpful
              • 4. Re: How to retrieve parameters after Process finish
                olddave Newbie

                I am using persistence. The users need to see an audit of the processes that have run.

                 

                The user guide talks about how to get at Process and Node data, not parameters you passed in? From what I read there it stores minimal information. Maybe my only way is to add a workitem that stores the parameter values as the last node in the workflow? Very clumsy.

                 

                Surely there must be a way to get parameters passed in that is easier than this? I would have thought a typical scenario would be to run a Process where a human task altered data that you then want back to use after theh Process has completed, without a specific Work Item being used to capture it.

                 

                Thx.

                 

                Ed

                • 5. Re: How to retrieve parameters after Process finish
                  Marie MM Newbie

                  There is also log for variables org.jbpm.process.audit.VariableInstanceLog.

                  JPAProcessInstanceDbLog log = new JPAProcessInstanceDbLog(getEnvironment());

                  List<VariableInstanceLog> results = log.findVariableInstances(processInstanceId, "OutcomeResult");

                  But it keeps only String values.

                   

                  For our usage I would prefare storing data as complex object, so we can work with them as when process is running and they are taken from ProcessInstanceInfo table.

                  If you have any idea or solution, share it.

                  • 6. Re: How to retrieve parameters after Process finish
                    olddave Newbie

                    We ended up getting our custom Work items to log the data we need for our Process management. Then we added a RESTful service to get this data and combine with the standard Process and Node data the console can provide. Ugly I know, but no choice given the lack of support for logging complex objects used in the jBPM 5.1 Process.

                     

                    Thanks for the suggestions.

                     

                    Ed