JBoss.orgCommunity Documentation
REST API calls to the execution server allow you to manage processes and tasks and retrieve various dynamic information from the execution server. All calls are synchronous, that is, the call will only complete, including the possible return of a result, once the requested operation has succeeded.
When using Java code to interface with the REST API, the classes used in POST operations or otherwise returned by various operations can be found
in the (org.kie.remote:)kie-services-client
jar.
Serialization (json/jaxb)
Except for the Execute calls, all other REST calls described below can use either JAXB or JSON.
All REST calls, unless otherwise specified, will use JAXB serialization.
When using JSON, make sure to add the JSON media type ("application/json"
) to the ACCEPT
header of your REST
call.
Some of the REST calls below return lists of information. The results of these operations can be paginated, which means that the lists can be split up and returned according to the parameters sent by the user.
For example, if the REST call parameters indicate that page 2 with page size 10 should be returned for the results, then results 10 to (and including) 19 will be returned.
The first page is always page 1 (as opposed to page "0").
Table 17.1. Pagination query parameter syntax
Parameter name | Description |
---|---|
page | This the page number requested. The default value is 1. |
p | This is a synonym for the above |
pageSize | This is the number of elements per page to return. The default value is 10. |
s | This is a synonym for the above |
If both a "long" pagination parameter and its synonym are used, then only the value from the "long" variant is used. For example, if
the page
is given with a value of 11 and the p
parameter is given with a value of 37, then the value of the page
parameter, 11, will be used and the p
parameter will be ignored.
For the following operations, pagination is always used. See above for the default values used.
Table 17.2. REST operations using pagination
REST call URL | Short Description |
---|---|
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
| Returns a list of |
If you're triggering an operation with a REST API call that would normally (e.g. when interacting the same operation on a local
KieSession
or TaskService
instance) take an instance of a java.util.Map
as one of it's parameters,
you can submit key-value pairs to the operation to simulate this behaviour by passing a query parameter whose name starts with
map_
.
Example 17.1.
If you pass the query parameter map_kEy=vAlue
in a REST call, then the Map
that's passed to the
actual underlying KieSession
or TaskService
operation will contain this (String, String
) key value pair:
"kEy" => "vAlue"
.You could pass this parameter like so:
http://localhost:8080/kie-wb/rest/runtime/myproject/process/wonka.factory.loompa.hire/start?map_kEy=vAlue
Map query parameters also use the object query parameter syntax described below, so the following query parameter,
map_total=5000
will be translated into a key-value pair in a map where the key is the String "total" and the value is a Long with the
value of 5000. For example:
http://localhost:8080/kie-wb/rest/runtime/myproject/process/wonka.factory.oompa.chocolate/start?map_total=5000
The following operations take query map parameters:
/runtime/{deploymentId}/process/{processDefId}/start
/runtime/{deploymentId}/workitem/{processItemId}/complete
/runtime/{deploymentId}/withvars/process/{processDefId}/start
/task/{taskId}/complete
/task/{taskId}/fail
While REST calls obviously only take strings as query parameters, using the following notation for query parameters will mean that the string is translated into a different type of object when the value of the string is used in the actual operation:
The REST calls allow access to the underlying deployments, regardless of whether these deployments use the Singleton
,
Per-Process-Instance
or Per-Request
strategies.
While there's enough information in the URL in order to access deployments that use the Singleton
, or Per-Request
strategies, that's not always the case with the Per-Process-Instance
runtimes because the REST operation will obviously
need the process instance id in order to identify the deployment.
Therefore, for REST calls for which the URL does not contain the process instance id, you'll need to add the following parameter:
Table 17.4. Per-Process-Instance runtime query parameter
Parameter name | Description |
---|---|
runtimeProcInstId | Query parameter that may only have numbers as it values: the value specify the process instance id that identifies the
underlying This parameter will have no effect if the underlying deployment uses the |
This section lists REST calls that interface with
The deploymentId component of the REST calls below must conform to the following regex:
[a-zA-Z0-9-:\.]+
/runtime/{deploymentId}/process/{processDefId}/start
Starts a process.
Returns a JaxbProcessInstanceResponse
instance, that contains basic information about the process instance.
The prodessDefId component of the URL must conform to the following regex:
[_a-zA-Z0-9-:\.]+
This operation takes map query parameters (see above), which will be used as parameters for the process instance.
/runtime/{deploymentId}/process/instance/{procInstId}
Does a (read only) retrieval of the process instance. This operation will fail (code 400) if the process instance has been completed.
Returns a JaxbProcessInstanceResponse
instance.
The procInstId component of the URL must conform to the following regex: [0-9]+
/runtime/{deploymentId}/process/instance/{procInstId+}/abort
Aborts the process instance.
Returns a JaxbGenericResponse
indicating whether or not the operation has succeeded.
The procInstId component of the URL must conform to the following regex: [0-9]+
/runtime/{deploymentId}/process/instance/{procInstId}/signal
Signals the process instance.
Returns a JaxbGenericResponse
indicating whether or not the operation has succeeded.
The procInstId component of the URL must conform to the following regex: [0-9]+
This operation takes a signal
and a event
query parameter.
The signal
parameter value is used as the name of the signal. This parameter is required.
The event
parameter value is used as the value of the event. This value may use the
number query parameter syntax described above.
/runtime/{deploymentId}/process/instance/{procInstId}/variables
Gets the list of process variables in a process instance.
Returns a JaxbVariablesResponse
The procInstId component of the URL must conform to the following regex: [0-9]+
/runtime/{deploymentId}/signal
Signals the KieSession
Returns a JaxbGenericResponse
indicating whether or not the operation has succeeded.
The procInstId component of the URL must conform to the following regex: [0-9]+
This operation takes a signal
and a event
query parameter.
The signal
parameter value is used as the name of the signal. This parameter is required.
The event
parameter value is used as the value of the event. This value may use the
number query parameter syntax described above.
/runtime/{deploymentId}/workitem/{workItemId}
Gets a WorkItem
instance
Returns a JaxbWorkItem
instance
The workItemId component of the URL must conform to the following regex:
[0-9]+
/runtime/{deploymentId}/workitem/{workItemId}/complete
Completes a WorkItem
Returns a JaxbGenericResponse
indicating whether or not the operation has succeeded
The workItemId component of the URL must conform to the following regex:
[0-9]+
This operation takes map query parameters, which are used as input to signify the results for completion of the work item.
/runtime/{deploymentId}/workitem/{workItemId: [0-9-]+}/abort
Aborts a WorkItem
Returns a JaxbGenericResponse
indicating whether or not the operation has succeeded
The workItemId component of the URL must conform to the following regex:
[0-9]+
/runtime/{deploymentId}/withvars/process/{processDefId}/start
Starts a process and retrieves the list of variables associated with the process instance
Returns a JaxbProcessInstanceWithVariablesResponse
that contains:
Information about the process instance (with the same fields and behaviour as the JaxbProcessInstanceResponse
A key-value list of the variables available in the process instance.
The processDefId component of the URL must conform to the following regex:
[_a-zA-Z0-9-:\.]+
/runtime/{deploymentId}/withvars/process/instance/{procInstId}
Starts a process and retrieves the list of variables associated with the process instance
Returns a JaxbProcessInstanceWithVariablesResponse
(see the above REST
call)
The processInstId component of the URL must conform to the following regex:
[0-9]+
/runtime/{deploymentId}/withvars/process/instance/{procInstId}/signal
Signals a process instance and retrieves the list of variables associated it
Returns a JaxbProcessInstanceWithVariablesResponse
(see above)
The processInstId component of the URL must conform to the following regex:
[0-9]+
The information that is available via the History REST calls is not limited to the deployment specfied by the
deploymentId part of the URL used. This is because the AuditLogService
used by the REST calls is
only dependent on the persistence framework used by the deployment, but not on anything else.
/runtime/{deploymentId}/history/clean
Cleans (deletes) all history logs
/runtime/{deploymentId}/history/instances
Gets a list of ProcessInstanceLog
instances
Returns a JaxbHistoryLogList
instance that contains a list of JaxbProcessInstanceLog
instances
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}
Gets the ProcessInstanceLog
instance associated with the specified process instance
Returns a JaxbHistoryLogList
instance that contains a JaxbProcessInstanceLog
instance
The processInstId component of the URL must conform to the following regex:
[0-9]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}/child
Gets a list of ProcessInstanceLog
instances associated with any
child/sub-processes associated with the specified process instance
Returns a JaxbHistoryLogList
instance that contains a list of JaxbProcessInstanceLog
instances
The processInstId component of the URL must conform to the following regex:
[0-9]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}/node
Gets a list of NodeInstanceLog
instances associated with the specified process
instance
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbNodeInstanceLog
instances
The processInstId component of the URL must conform to the following regex:
[0-9]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}/variable
Gets a list of VariableInstanceLog
instances associated with the specified process
instance
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbVariableInstanceLog
instances
The processInstId component of the URL must conform to the following regex:
[0-9]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}/node/{nodeId}
Gets a list of NodeInstanceLog
instances associated with the specified
process instance that have the given (node) id
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbNodeInstanceLog
instances
The processInstId component of the URL must conform to the following regex:
[0-9]+
The nodeId component of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/instance/{procInstId}/variable/{varId}
Gets a list of VariableInstanceLog
instances associated with the specified
process instance that have the given (variable) id
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbVariableInstanceLog
instances
The processInstId component of the URL must conform to the following regex:
[0-9]+
The varId component of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/process/{processDefId}
Gets a list of ProcessInstanceLog
instances associated with the specified
process definition
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbProcessInstanceLog
instances
The processDefId component of the URL must conform to the following regex:
[_a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/variable/{varId}
Gets a list of VariableInstanceLog
instances associated with the specified variable id
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbVariableInstanceLog
instances
The varId component of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/variable/{varId}/value/{value}
Gets a list of VariableInstanceLog
instances associated with the specified variable id
that contain the value specified
Returns a JaxbHistoryLogList
instance that contains a list of
JaxbVariableInstanceLog
instances
Both the varId and value components of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/variable/{varId}/instances
Gets a list of ProcessInstance
instances that contain the variable specified by
the given variable id.
Returns a JaxbProcessInstanceListResponse
instance that contains a list of
JaxbProcessInstanceResponse
instances
The varId component of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
/runtime/{deploymentId}/history/variable/{varId}/value/{value}/instances
Gets a list of ProcessInstance
instances that contain the variable specified by
the given variable id which contains the (variable) value specified
Returns a JaxbProcessInstanceListResponse
instance that contains a list of
JaxbProcessInstanceResponse
instances
Both the varId and value components of the URL must conform to the following regex:
[a-zA-Z0-9-:\.]+
This operation responds to pagination parameters
All of the task operation calls described in this section use the user (id) used in the REST basic authorization as input for the user parameter in the specific call.
Some of the operations take an optional lanaguage
query parameter. If this parameter is not specified
in the REST call, the default value of "en-UK
" is used.
The taskId component of the REST calls below must conform to the following regex:
[0-9]+
/task/{taskId}/activate
Activates a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/claim
Claims a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/claimnextavailable
Claims the next available task
Returns a JaxbGenericResponse
with the status of the operation
Takes an optional language
query parameter.
/task/{taskId}/complete
Completes a task
Returns a JaxbGenericResponse
with the status of the operation
Takes map query parameters, which are the "results" input for the complete operation
/task/{taskId}/delegate
Delegates a task
Returns a JaxbGenericResponse
with the status of the operation
Requires a targetId
query parameter, which identifies the user or group
to which the task is delegated
/task/{taskId}/exit
Exits a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/fail
Fails a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/forward
Delegates a task
Returns a JaxbGenericResponse
with the status of the operation
Requires a targetId
query parameter, which identifies the user or group
to which the task is forwarded
/task/{taskId}/nominate
Nominates a task
Returns a JaxbGenericResponse
with the status of the operation
Requires at least one of either the user
or group
query parameter,
which identify the user(s) or group(s) that are nominated for the task
/task/{taskId}/release
Releases a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/resume
Resumes a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/skip
Skips a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/start
Starts a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/stop
Stops a task
Returns a JaxbGenericResponse
with the status of the operation
/task/{taskId}/suspend
Suspends a task
Returns a JaxbGenericResponse
with the status of the operation
/task/query
The /task/query
operation..
Queries the available (non-archived) tasks
Returns a JaxbTaskSummaryListResponse
with a list of TaskSummaryImpl
instances.
Takes the following (case-insensitive) query parameters listed below:
businessAdministrator
Specifies that the returned tasks should have the business administrator identified by this parameter
This parameter may be repeated
potentialOwner
Specifies that the returned tasks should have the potential owner identified by this parameter
This parameter may be repeated
processInstanceId
Specifies that the returned tasks should be associated with the process instance identified by this parameter
This parameter may be repeated
status
Specifies that the returned tasks should have the status identified by this parameter
This parameter may be repeated
taskId
Specifies that the returned tasks should have the (task) id identified by this parameter
This parameter may be repeated
taskOwner
Specifies that the returned tasks should have the task owner (initiator) identified by this parameter
This parameter may be repeated
workItemId
Specifies that the returned tasks should be associated with the work item identified by this parameter
This parameter may be repeated
union
This specifies whether the query should query the union or intersection of the parameters. See below for more info.
This parameter must only be passed once
Except for the union parameter, if any of the other parameters are passed multiple
times, this operation will query tasks based on the union of all values specific
parameter. This is always true, regardless of the value of the union
parameter.
For example, if multiple taskOwner
parameters are passed, this
operation will return all tasks that have a task owner matching at least one of the
passed values.
However, behaviour with regards to multiple (types of)
parameters is governed by the union
parameter: if the
union
parameter is passed as false
, then the operation will
query based on the intersection of the two sets of values.
For example, if both a taskOwner
and taskId
parameter
are passed as well as a union
parameter with a value of
false
, then the operation will query for tasks that have
both the specified task owner and task id.
However, if the union
parameter in the above example is
true
, then the operation will query for tasks that have
either the specified task owner or the
specified task id.
/task/{taskId}/content
Gets the task content from a task identified by the given task id
Returns a JaxbContent
with the content of the task
The taskId component of the URL must conform to the following regex:
[0-9]+
/task/content/{contentId}
Gets the task content from a task identified by the given content id
Returns a JaxbContent
with the content of the task
The contentId component of the URL must conform to the following regex:
[0-9]+
While there is a /runtime/{id}/execute
and a task/execute
method, both will take all types
of commands. This is possible because execute takes a JaxbCommandsRequest object, which contains
a list of (org.kie.api.command.)Command
objects. The JaxbCommandsRequest
has fields to store
the proper deploymentId
and processInstanceId
information.
Of course, if you send a command that needs this information (deploymentId
, for example)
and don't fill it in, this will fail.
/task/execute
Executes a Command
, assumed to be related to tasks.
Returns a JaxbCommandResponse
implementation with the result of the operation
/runtime/{deploymentId}/execute
Executes a Command
, assumed to be related to business processes or the knowledge session.
Returns a JaxbCommandResponse
implementation with the result of the operation
When the Workbench is deployed, it automatically creates 3 queues:
jms/queue/KIE.SESSION
jms/queue/KIE.TASK
jms/queue/KIE.RESPONSE
The KIE.SESSION
and KIE.TASK
queues should be used to send command request messages to the JMS API. Command response
messages will be then placed on the KIE.RESPONSE
. Command request messages that involve starting and managing business processes
should be sent to the KIE.SESSION
and command request messages that involve managing human tasks, should be sent to the
KIE.TASK
queue.
Although there are 2 different input queues, KIE.SESSION
and KIE.TASK
, this is only in order to provide multiple
input queues so as to optimize processing: command request messages will be processed in the same manner regardless of which queue they're sent to.
However, in some cases, users may send many more requests involving human tasks than requests involving business processes, but then not want the
processing of business process-related request messages to be delayed by the human task messages. By sending the appropriate command request
messages to the appropriate queues, this problem can be avoided.
The term "command request message" used above refers to a JMS byte message that contains a serialized
JaxbCommandsRequest
object. At the moment, only XML serialization (as opposed to, JSON or protobuf, for example) is supported.
The following is a rather long example that shows how to use the JMS API. The numbers ("callouts") along the side of the example refer to notes below that explain particular parts of the example. It's supplied for those advanced users that do not wish to use the jBPM Remote Java API.
The jBPM Remote Java API, described here, will otherwise take care of all of the logic shown below.
import java.util.List;
import java.util.UUID;
import javax.jms.*;
import javax.naming.*;
import javax.xml.bind.JAXBException;
import org.drools.core.command.runtime.process.StartProcessCommand;
import org.jbpm.services.task.commands.GetTaskAssignedAsPotentialOwnerCommand;
import org.kie.api.command.Command;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.task.model.TaskSummary;import org.kie.services.client.serialization.jaxb.JaxbSerializationProvider;
import org.kie.services.client.serialization.jaxb.impl.JaxbCommandResponse;
import org.kie.services.client.serialization.jaxb.impl.JaxbCommandsRequest;
import org.kie.services.client.serialization.jaxb.impl.JaxbCommandsResponse;
import org.kie.services.client.serialization.jaxb.impl.JaxbExceptionResponse;
// ...
String USER = "charlie";
String PASSWORD = "ch0c0licious";
String DEPLOYMENT_ID = "test-project";
String PROCESS_ID_1 = "oompa-processing";
// Create command
Command<?> cmd = new StartProcessCommand(PROCESS_ID_1);int oompaProcessingResultIndex = 0;
JaxbCommandsRequest req = new JaxbCommandsRequest(DEPLOYMENT_ID, cmd);
req.getCommands().add(new GetTaskAssignedAsPotentialOwnerCommand(USER, "en-UK"));int loompaMonitoringResultIndex = 1;
// Setup queues
InitialContext context;
Queue sendQueue, responseQueue;
try {
context = new InitialContext();
sendQueue = (Queue) context.lookup("jms/queue/KIE.SESSION");
responseQueue = (Queue) context.lookup("jms/queue/KIE.RESPONSE");
} catch( NamingException ne ) {
throw new RuntimeException("Unable to lookup send or response queue", ne);
}
Connection connection = null;
Session session = null;
JaxbCommandsResponse cmdResponse = null;
String corrId = UUID.randomUUID().toString();
String selector = "JMSCorrelationID = '" + corrId + "'";
try {
// Create JMS connection and session
MessageProducer producer;
MessageConsumer consumer;
try {
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
connection = connectionFactory.createConnection(USER, PASSWORD);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(sendQueue);
consumer = session.createConsumer(responseQueue, selector);
connection.start();
} catch (JMSException jmse) {
throw new RuntimeException("Unable to setup a JMS connection.", jmse);
} catch (NamingException ne) {
throw new RuntimeException("Unable to lookup JMS connection factory.", ne);
}
// Create msg
BytesMessage msg;
try {msg = session.createBytesMessage();
msg.setJMSCorrelationID(corrId);
msg.setIntProperty("serialization", JaxbSerializationProvider.JMS_SERIALIZATION_TYPE);
String xmlStr = JaxbSerializationProvider.convertJaxbObjectToString(req);
msg.writeUTF(xmlStr);
} catch (JMSException jmse) {
throw new RuntimeException("Unable to create and fill a JMS message.", jmse);
} catch (JAXBException jaxbe) {
throw new RuntimeException("Unable to deserialze JMS message.", jaxbe);
}
// Send msg
try {
producer.send(msg);
} catch (JMSException jmse) {
throw new RuntimeException("Unable to send a JMS message.", jmse);
}
// receive
Message response;
try {
long qualityOfServiceThresholdMilliSeconds = 5 * 1000;
response = consumer.receive(qualityOfServiceThresholdMilliSeconds);
} catch (JMSException jmse) {
throw new RuntimeException("Unable to receive or retrieve the JMS response.", jmse);
}
// extract response
assert response != null : "Response is empty.";
try {
String xmlStr = ((BytesMessage) response).readUTF();cmdResponse = (JaxbCommandsResponse) JaxbSerializationProvider.convertStringToJaxbObject(xmlStr);
} catch (JMSException jmse) {
throw new RuntimeException("Unable to extract " + JaxbCommandsResponse.class.getSimpleName()
+ " instance from JMS response.", jmse);
} catch (JAXBException jaxbe) {
throw new RuntimeException("Unable to extract " + JaxbCommandsResponse.class.getSimpleName()
+ " instance from JMS response.", jaxbe);
}
assert cmdResponse != null : "Jaxb Cmd Response was null!";
} finally {
if (connection != null) {
try {
connection.close();
session.close();
} catch (JMSException jmse) {
System.out.println("Unable to close connection or session!");
jmse.printStackTrace();
}
}
}
ProcessInstance oompaProcInst = null;
List<TaskSummary> charliesTasks = null;
for (JaxbCommandResponse<?> response : cmdResponse.getResponses()) {if (response instanceof JaxbExceptionResponse) {
JaxbExceptionResponse exceptionResponse = (JaxbExceptionResponse) response;
throw new RuntimeException(exceptionResponse.getMessage());
}if (response.getIndex() == oompaProcessingResultIndex) {
oompaProcInst = (ProcessInstance) response.getResult();
} else if (response.getIndex() == loompaMonitoringResultIndex) {
charliesTasks = (List<TaskSummary>) response.getResult();
}
}
These classes can all be found in the (org.kie.remote:)kie-services-client jar. | |
The A deployment id is required for command request messages that deal with business processes. Command request messages that only contain human task-related commands do not require a deployment id. | |
Note that the JMS message sent to the remote JMS API must be constructed as follows:
| |
The same serialization mechanism used to serialize the request message will be used to serialize the response message. | |
In order to match the response to a command, to the initial command, use the | |
Since many of the results returned by various commands are not serializable, the jBPM JMS Remote API converts these results
into JAXB equivalents, all of which implement the For example, in the code above, the However, not all methods that can be called on a normal |
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.
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
Table 17.5. Pagination query parameter syntax
Variable | Possible value | Description |
---|---|---|
deploymentId | myproject | This is the name (id) of the deployment the |
deploymentURL | http://localhost:8080/kie-wb/ | This is the base URL that should be used when interacting with the remote execution-server. |
user | homer | This is the user needed for authentication for all rest calls. |
password | d0nutsd0nutsILUVDONUTS! | This is the password for the user specified in the |
See the various constructors of the RemoteRestSessionFactory
class for more possibilities.