Search This Blog

Tuesday, September 13, 2016

jBPM Remote Java API

Remote Java API

Using the Remote Java RuntimeEngine API

By using the RemoteRestSessionFactory or RemoteJmsSessionFactory classes provided by the kie-services-client jar, you can create remote instances of the RuntimeEngine and thus also the KieSession and TaskService. These instances will allow you to interact with a remote workbench instance (i.e. KIE workbench or the jBPM Console) without having to deal with the underlying transport and serialization details.

The REST Remote Java RuntimeEngine

In order to interact via REST with the remote runtime, the RemoteRestSessionFactory can be used. The following example illustrates how the remote session can be used.
  // Create REST session

  RemoteRestSessionFactory restSessionFactory 

    = new RemoteRestSessionFactory(deploymentId, deploymentUrl, user, password);   

  RuntimeEngine engine = restSessionFactory.newRuntimeEngine();

  KieSession ksession = engine.getKieSession();

  ProcessInstance processInstance = ksession.startProcess("org.jbpm.humantask");

  

  TaskService taskService = engine.getTaskService();

  List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(taskUserId, "en-UK");

  long taskId = findTaskId(processInstance.getId(), tasks);

  

  Task task = taskService.getTaskById(taskId);

  

  taskService.start(taskId, taskUserId);

  taskService.complete(taskId, taskUserId, null);
In the above example, the following variables were used when initalizing the RemoteRestSessionFactory




Pagination query parameter syntax
VariablePossible valueDescription
deploymentIddemoproject
This is the name (id) of the deployment the RuntimeEngineshould interact with.
deploymentURLhttp://localhost:8080/kie-wb/
This is the base URL that should be used when interacting with the remote execution-server.
userkrisvThis is the user needed for authentication for all rest calls.
passwordpa$$w0rd
This is the password for the user specified in the userparameter.

See the various constructors of the RemoteRestSessionFactory class for more possibilities.



No comments:

Post a Comment