3 Replies Latest reply on Apr 25, 2016 3:28 AM by Muthu Veerappan

    How to get process instance variables through jBPM Java Remote API

    Jaime Izuzquiza Suárez-Inclán Newbie

      Hi all,

       

      is is possible to retrieve values of process instance variables through jBPM Java Remote API (kie-remote-client 6.2)?

       

      Thanks in advance.

        • 1. Re: How to get process instance variables through jBPM Java Remote API
          Muthu Veerappan Newbie

          Jamie,

          Use the below code to retrieve the process instance variables as a Map<String,Object>. I have tested it, works fine!

           

          ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());

            RuleFlowProcessInstance rfpi = (RuleFlowProcessInstance)pi;

            Map<String,Object> variable = rfpi.getVariables();

            System.out.println(variable);

          • 2. Re: How to get process instance variables through jBPM Java Remote API
            Jaime Izuzquiza Suárez-Inclán Newbie

            Muthu,

             

            I don't find any RuleFlowProcessInstance class definition in kie-remote-client...

            • 3. Re: How to get process instance variables through jBPM Java Remote API
              Muthu Veerappan Newbie

              Try these 4 dependencies

              <dependency>

                <groupId>org.kie</groupId>

                <artifactId>kie-api</artifactId>

                <version>6.3.0.Final</version>

                </dependency>

               

               

                <dependency>

                <groupId>org.kie</groupId>

                <artifactId>kie-internal</artifactId>

                <version>6.3.0.Final</version>

                </dependency>

               

               

                <dependency>

                <groupId>org.jbpm</groupId>

                <artifactId>jbpm-flow</artifactId>

                <version>6.3.0.Final</version>

                </dependency>

               

               

                <dependency>

                <groupId>org.jbpm</groupId>

                <artifactId>jbpm-test</artifactId>

                <version>6.3.0.Final</version>

                </dependency>

               

               

              Code for the same

               

              package com.sample;

               

               

              import java.io.IOException;

              import java.util.HashMap;

              import java.util.Map;

               

               

              import org.jbpm.ruleflow.instance.RuleFlowProcessInstance;

              import org.jbpm.test.JbpmJUnitBaseTestCase;

              import org.junit.Test;

              import org.kie.api.runtime.KieSession;

              import org.kie.api.runtime.manager.RuntimeEngine;

              import org.kie.api.runtime.manager.RuntimeManager;

              import org.kie.api.runtime.process.ProcessInstance;

               

               

              /**

              * This is a sample file to test a process.

              */

              public class ProcessTest extends JbpmJUnitBaseTestCase {

               

               

                @Test

                public void testProcess() throws IOException {

                RuntimeManager manager = createRuntimeManager("com/sample/sample.bpmn");

                RuntimeEngine engine = getRuntimeEngine(null);

                KieSession ksession = engine.getKieSession();

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

                map.put("input", "VALUE");

               

                ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello",map);

                System.out.println(processInstance.getId());

               

                ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());

                RuleFlowProcessInstance rfpi = (RuleFlowProcessInstance)pi;

                Map<String,Object> variable = rfpi.getVariables();

                System.out.println(variable);

               

                }

              }

               

              You can use the same dependencies along with remote client.