JBoss.orgCommunity Documentation
The workbench contains an execution server (for executing processes and tasks), which also allows you to invoke various process and task related operations through a remote API. As a result, you can setup your process engine "as a service" and integrate this into your applications easily by doing remote requests and/or sending the necessary triggers to the execution server whenever necessary (without the need to embed or manage this as part of your application).
Both a REST and JMS based service are available (which you can use directly), and a Java remote client allows you to invoke these operations using the existing KieSession and TaskService interfaces (you also use for local interaction), making remote integration as easy as if you were interacting with a local process engine.
Remote Rest Runtime Engine Builder methods
addDeploymentId(String deploymentId)
when
addExtraJaxbClasses(Class… extraJaxbClasses )
when
Add extra classes to the classpath available to the serialization mechanisms
addPassword(String password)
always
addProcessInstanceId(long process)
when
addTimeout(int timeoutInSeconds)
addUrl(URL serverInstanceUrl)
always
Set the URL for the application instance
This should be a URL that roughly corresponds to
http://server:port/business-central/
or
http://server:port/kie-wb/
.
addUserName(String userName)
always
clearJaxbClasses()
The following example illustrates how the Remote Java API can be used with the REST API.
public void startProcessAndHandleTaskViaRestRemoteJavaAPI(URL serverRestUrl, String deploymentId, String user, String password) {
// the serverRestUrl should contain a URL similar to "http://localhost:8080/jbpm-console/"
// Setup the factory class with the necessarry information to communicate with the REST services
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()
.addUrl(serverRestUrl)
.addTimeout(5)
.addDeploymentId(deploymentId)
.addUserName(user)
.addPassword(password)
// if you're sending custom class parameters, make sure that
// the remote client instance knows about them!
.addExtraJaxbClasses(MyType.class)
.build();
// Create KieSession and TaskService instances and use them
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
// Each operation on a KieSession, TaskService or AuditLogService (client) instance
// sends a request for the operation to the server side and waits for the response
// If something goes wrong on the server side, the client will throw an exception.
Map<String, Object> params = new HashMap<String, Object>();
params.put("paramName", new MyType("name", 23));
ProcessInstance processInstance
= ksession.startProcess("com.burns.reactor.maintenance.cycle", params);
long procId = processInstance.getId();
String taskUserId = user;
taskService = engine.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(user, "en-UK");
long taskId = -1;
for (TaskSummary task : tasks) {
if (task.getProcessInstanceId() == procId) {
taskId = task.getId();
}
}
if (taskId == -1) {
throw new IllegalStateException("Unable to find task for " + user +
" in process instance " + procId);
}
taskService.start(taskId, taskUserId);
// resultData can also just be null
Map<String, Object> resultData = new HashMap<String, Object>();
taskService.complete(taskId, taskUserId, resultData);
}
Remote JMS Runtime Engine Builder methods
addConnectionFactory(ConnectionFactory connectionFactory)
when
Add a ConnectionFactory
used to create JMS session to send and receive messages
addDeploymentId(String deploymentId)
when
addExtraJaxbClasses(Class… extraJaxbClasses )
when
addHostName(String hostname)
when
Set the host name for the server that the client is making a JMS connection with
addJbossServerHostName(String hostname)
Set the host name of the JBoss EAP server that the client is making a JMS connection with
addJmsConnectorPort(int port)
when
Set the port used for the JMS connection connection with the server
addKeystoreLocation(String keystorePath)
when
addKeystorePassword(String keystorePassword)
when
addKieSessionQueue(Queue ksessionQueue)
when
addPassword(String password)
always
addProcessInstanceId(long process)
when
addRemoteInitialContext(InitialContext remoteInitialContext)
addResponseQueue(Queue responseQueue)
when
addTaskServiceQueue(Queue taskServiceQueue)
when
addTimeout(int timeoutInSeconds)
addTruststoreLocation(String truststorePath)
when
addTruststoreLocation(String truststorePassword)
when
addUserName(String userName)
always
Set the name of the user connecting to the server
This is also the user whose permissions will be used when doing any task operations
clearJaxbClasses()
disableTaskSecurity()
useKeystoreAsTruststore()
Starting with this release, a simple webservice has been added to the remote API.
Remote Webservice Client Builder methods
addDeploymentId(String deploymentId)
when
addExtraJaxbClasses(Class… extraJaxbClasses )
when
addServerUrl(URL applicationUrl)
always
addPassword(String password)
always
addTimeout(int timeoutInSeconds)
addUserName(String userName)
always
Set the name of the user connecting to the server
This is also the user whose permissions will be used when doing any task operations
setWsdlLocationRelativePath()
useHttpRedirect()
Table 17.2. Available rules-related KieSession
methods<
Return type | Method signature | Description |
---|---|---|
|
|
Return the total fact count |
|
|
Return a global fact |
|
|
Return the id of the |
|
|
Set a global fact |
|
|
Fire all rules |
Table 17.3. Available WorkItemManager
methods
Return type | Method signature | Description |
---|---|---|
|
|
Abort the work item |
|
|
Complete the work item |
|
|
Return the work item |
Table 17.4. Available task operation TaskService
methods
Return type | Method signature | Description |
---|---|---|
|
|
Add a new task |
|
|
Activate a task |
|
|
Claim a task |
|
|
Claim a task |
|
|
Claim the next available task for a user |
|
|
Claim the next available task for a user |
|
|
Complete a task |
|
|
Delegate a task |
|
|
Exit a task |
|
|
Fail a task |
|
|
Forward a task |
|
|
Nominate a task |
|
|
Release a task |
|
|
Remove a task |
|
|
Resume a task |
|
|
Skip a task |
|
|
Start a task |
|
|
Stop a task |
|
|
Suspend a task |
Table 17.5. Available task retrieval and query TaskService
methods
Return type | Method signature |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`List<TaskSummary> |
|
|
|
|
|
|
|
Table 17.6. Available AuditService
methods
Return type | Method signature |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This section lists REST calls that interface process instances.
The deploymentId component of the REST calls below must conform to the following regular expression:
[\w\.-]+(:[\w\.-]+){2,2}(:[\w\.-]*){0,2}
For more information about the composition of the deployment id, see the Deployment Calls section.
[POST]
/runtime/{deploymentId}/process/{processDefId}/start
[POST]
rest/runtime/{deploymentId}/process/{processDefId}/startform
[GET]
/runtime/{deploymentId}/process/instance/{procInstId}
[POST]
/runtime/{deploymentId}/process/instance/{procInstId+}/abort
[POST]
/runtime/{deploymentId}/process/instance/{procInstId}/signal
[GET]
/runtime/{deploymentId}/process/instance/{procInstId}/variable/{varName}
[POST]
/runtime/{deploymentId}/signal
[GET]
/runtime/{deploymentId}/workitem/{workItemId}
[POST]
/runtime/{deploymentId}/workitem/{workItemId}/complete
[POST]
/runtime/{deploymentId}/workitem/{workItemId: [0-9-]+}/abort
[POST]
/runtime/{deploymentId}/withvars/process/{processDefId}/start
[POST]
/runtime/{deploymentId}/withvars/process/instance/{procInstId}
[POST]
/runtime/{deploymentId}/withvars/process/instance/{procInstId}/signal
[GET]
/history/instance/{procInstId}
[GET]
/history/instance/{procInstId}/child
[GET]
/history/instance/{procInstId}/node
[GET]
/history/instance/{procInstId}/variable
[GET]
/history/instance/{procInstId}/node/{nodeId}
[GET]
/history/instance/{procInstId}/variable/{varId}
[GET]
/history/process/{processDefId}
[GET]
/history/variable/{varId}
[GET]
/history/variable/{varId}/value/{value}
[GET]
/history/variable/{varId}/instances
[GET]
/history/variable/{varId}/value/{value}/instances
ProcessInstance
instances that contain the variable specified by the given variable id which contains the (variable) value specifiedJaxbProcessInstanceListResponse
instance that contains a list of JaxbProcessInstanceResponse
instances[GET]
/runtime/{deploymentId}/history/variable/{varId}
[GET]
/runtime/{deploymentId}/history/variable/{varId}/value/{value}
[GET]
/runtime/{deploymentId}/history/variable/{varId}/instances
[GET]
/runtime/{deploymentId}/history/variable/{varId}/value/{value}/instances
ProcessInstance
instances that contain the variable specified by the given variable id which contains the (variable) value specifiedJaxbProcessInstanceListResponse
instance that contains a list of JaxbProcessInstanceResponse
instancesWith regards to retrieving information, only users associated with a task may retrieve information about the task. However, the authorizations of progress and other modifications of task information are more complex. See the Task Permissions section in the Task Service documentation for more infomration.
Given that many users have expressed the wish for a "super-task-user" that can execute task REST operations on all tasks, regardless of the users associated with the task, there are now plans to implement that feature. However, so far for the 6.x releases, this feature is not available.
The taskId component of the REST calls below must conform to the following regex:
[0-9]+
[POST]
/task/{taskId}/activate
[POST]
/task/{taskId}/claimnextavailable
[POST]
/task/{taskId}/delegate
[POST]
/task/{taskId}/nominate
/task/query
operation queries all non-archived tasks based on the parameters given.JaxbTaskSummaryListResponse
with a list of TaskSummaryImpl
All parameters except for the union
parameter may be repeated.
businessAdministrator
potentialOwner
processInstanceId
status
taskId
taskOwner
workItemId
language
union
`[\w\.-]+(:[\w\.-]+){2,2}(:[\w\.-]*){0,2}`
This regular expression is explained as follows:
This [\w\.-]
element occurs at least 3 times and at most 5 times, separated by a :
character each time.
Example 17.2. Accepted deploymentId's
com.wonka:choco-maker:67.190
These example `deploymentId’s contain the optional kbase and ksession id groups.
com.wonka:choco-maker:67.190:oompaBase
com.wonka:choco-maker:67.190:oompaLoompaBase:gloopSession
There are 2 operations that can be used to modify the status of a deployment:
RFC 2616: "the request has been accepted for processing, but the processing has not been completed."
This means the following:
GET
operations described below, are snapshots and the information (including the status of the
deployment unit) may have changed by the time the user client receives the answer to the GET
request.[GET]
/deployment/ {deploymentId}
[POST]
/deployment/{deploymentId}/deploy
JaxbDeploymentJobResult
instance with the status of the request
GET
calls
described above.Since deployment descriptors can be merged differently, it’s possibile to provide the merge mode as part of deploy request by adding query parameter:
mergemode
where values should be one of the following
Table 17.9. Task commands
ActivateTaskCommand |
FailTaskCommand |
GetTasksOwnedCommand |
AddTaskCommand |
ForwardTaskCommand |
NominateTaskCommand |
CancelDeadlineCommand |
GetAttachmentCommand |
ProcessSubTaskCommand |
ClaimNextAvailableTaskCommand |
GetContentCommand |
ReleaseTaskCommand |
ClaimTaskCommand |
GetTaskAssignedAsBusinessAdminCommand |
ResumeTaskCommand |
CompleteTaskCommand |
GetTaskAssignedAsPotentialOwnerCommand |
SkipTaskCommand |
CompositeCommand |
GetTaskByWorkItemIdCommand |
StartTaskCommand |
DelegateTaskCommand |
GetTaskCommand |
StopTaskCommand |
ExecuteTaskRulesCommand |
GetTasksByProcessInstanceIdCommand |
SuspendTaskCommand |
Table 17.10. History/Audit commands
ClearHistoryLogsCommand |
FindProcessInstanceCommand |
FindSubProcessInstancesCommand |
FindActiveProcessInstancesCommand |
FindProcessInstancesCommand |
FindVariableInstancesByNameCommand |
FindNodeInstancesCommand |
FindSubProcessInstancesCommand |
FindVariableInstancesCommand |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<command-request>
<deployment-id>org.jbpm:Evaluation:1.0</deployment-id>
<ver>6.2.0.1</ver>
<user>krisv</user>
<start-process processId="evaluation">
<parameter>
<item key="reason">
<value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Yearly performance evaluation</value>
</item>
<item key="employee">
<value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">krisv</value>
</item>
</parameter>
</start-process>
</command-request>
Note that the request should also contain the following HTTP headers:
application/xml
The response will contain information about the process instance that was just started:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<command-response>
<deployment-id>org.jbpm:Evaluation:1.0</deployment-id>
<ver>6.2.0.1</ver>
<process-instance index="0">
<process-id>evaluation</process-id>
<id>15</id>
<state>1</state>
<parentProcessInstanceId>0</parentProcessInstanceId>
<command-name>StartProcessCommand</command-name>
</process-instance>
</command-response>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<command-request>
<deployment-id>demo:testproject:1.0</deployment-id>
<ver>6.2.0.1</ver>
<user>krisv</user>
<start-process processId="testproject.testprocess">
<parameter>
<item key="testobject">
<value xsi:type="testObject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<field1>1</field1>
<field2>2</field2>
</value>
</item>
</parameter>
</start-process>
</command-request>
The 3 headers that therefore need to be set in the requst are the following:
application/xml
The rich query operations can be reached via the following URLs:
http://server.address:port/{application-id}/rest/query/ runtime task * [GET] rich query for task summaries and process variables process * [GET] rich query for process instances and process variables
processInstanceId
, taskId
and tid
. The case (lowercase
or uppercase) of these parameters does not matter, except when the query parameter
also specifies the name of a user-defined variable.org.process.frombulator
, 29
and harry
.When you submit a REST call to the query operation, your URL will look something like this:
http://localhost:8080/business-central/rest/query/runtime/process/processId=org.process.frombulator&piid=29
[1] The date operations take strings with a specific date format as their values: yy-MM-dd_HH:mm:ss
.
However, users can also submit only part of the date:
yy-MM-dd
) means that a time of 00:00:00 is used (the beginning of the day).HH:mm:ss
) means that the current date is used.Table 17.12. Example date strings
Date str ing | Actual meaning |
---|---|
|
May 29th, 2015, 13:40:12 (1:40:12 PM) |
|
November 20th, 2014, 00:00:00 |
|
Today, 9:30:00 (AM) |
For the format used, see the SimpleDateFormat documentation.
[2] The var
query parameter is used differently than other parameters. If you want to specify
both the variable id and value of a variable (as opposed to just the variable id), then you can
do it by using the var
query parameter. The syntax is var_<variable-id>=<variable-value>
[3] The varreggex
(or shortened version vr
) parameter works similarly to the var
query
parameter. However, the value part of the query parameter can be a regular expression.
[4] By default, only the information from most recent (last) variable instance logs is retrieved. However, users can also retrieve all variable instance logs (that match the given criteria) by using this parameter.
The process instance query returns a JaxbQueryProcessInstanceResult instance.
The task query returns a JaxbQueryTaskResult instance.
Results are structured as follows:
A JaxbQueryProcessInstanceInfo object contains:
A JaxbQueryTaskInfo info object contains:
When users wish to include their own classes with requests, there a number of requirements that must be met for the user-defined classes. For more information about these requirements, see the Sending and receiving user class instances section in the remote API additional documentation section.
The jBPM Remote Java API, described here, will otherwise take care of all of the logic shown below.
package org.kie.remote.client.documentation.jms;
import static org.kie.services.client.serialization.SerializationConstants.DEPLOYMENT_ID_PROPERTY_NAME;
import static org.kie.services.client.serialization.SerializationConstants.SERIALIZATION_TYPE_PROPERTY_NAME;
import static org.kie.services.shared.ServicesVersion.VERSION;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.kie.api.command.Command;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.task.model.TaskSummary;
import org.kie.remote.client.api.RemoteRuntimeEngineFactory;
import org.kie.remote.client.api.exception.MissingRequiredInfoException;
import org.kie.remote.client.api.exception.RemoteApiException;
import org.kie.remote.client.api.exception.RemoteCommunicationException;
import org.kie.remote.client.jaxb.ClientJaxbSerializationProvider;
import org.kie.remote.client.jaxb.JaxbCommandsRequest;
import org.kie.remote.client.jaxb.JaxbCommandsResponse;
import org.kie.remote.jaxb.gen.AuditCommand;
import org.kie.remote.jaxb.gen.GetTaskAssignedAsPotentialOwnerCommand;
import org.kie.remote.jaxb.gen.StartProcessCommand;
import org.kie.remote.jaxb.gen.TaskCommand;
import org.kie.services.client.serialization.JaxbSerializationProvider;
import org.kie.services.client.serialization.SerializationException;
import org.kie.services.client.serialization.SerializationProvider;
import org.kie.services.client.serialization.jaxb.impl.JaxbCommandResponse;
import org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SendJmsExample {
protected static final Logger logger = LoggerFactory.getLogger(SendJmsExample.class);
public void sendCommandsViaJms( String user, String password, String connectionUser, String connectionPassword,
String deploymentId, String processId, String hostName ) {
/**
* JMS setup
*/
// Get JNDI context from server
InitialContext context = RemoteRuntimeEngineFactory.getRemoteJbossInitialContext(hostName, connectionUser, connectionPassword);
// Create JMS connection
ConnectionFactory connectionFactory;
try {
connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
} catch( NamingException ne ) {
throw new RuntimeException("Unable to lookup JMS connection factory.", ne);
}
// Setup queues
Queue sessionQueue, taskQueue, sendQueue, responseQueue;
try {
sendQueue = sessionQueue = (Queue) context.lookup("jms/queue/KIE.SESSION");
taskQueue = (Queue) context.lookup("jms/queue/KIE.TASK");
responseQueue = (Queue) context.lookup("jms/queue/KIE.RESPONSE");
} catch( NamingException ne ) {
throw new RuntimeException("Unable to lookup send or response queue", ne);
}
/**
* Command preparation
*/
StartProcessCommand startProcCmd = new StartProcessCommand();
startProcCmd.setProcessId(processId);
/**
* Send command via JMS and receive response
*/
SerializationProvider serializationProvider = ClientJaxbSerializationProvider.newInstance();
ProcessInstance procInst = (ProcessInstance) sendJmsCommand(startProcCmd,
connectionUser, connectionPassword,
user, password, deploymentId, null,
connectionFactory, sendQueue, responseQueue,
serializationProvider, Collections.EMPTY_SET, JaxbSerializationProvider.JMS_SERIALIZATION_TYPE,
5 * 1000);
/**
* Command preparation
*/
GetTaskAssignedAsPotentialOwnerCommand gtaapoCmd = new GetTaskAssignedAsPotentialOwnerCommand();
gtaapoCmd.setUserId(user);
// Send command request
Long processInstanceId = null; // needed if you're doing an operation on a PER_PROCESS_INSTANCE deployment
/**
* Send command via JMS and receive response
*/
@SuppressWarnings("unchecked")
List<TaskSummary> taskSumList = (List<TaskSummary>) sendJmsCommand(gtaapoCmd,
connectionUser, connectionPassword,
user, password, deploymentId, processInstanceId,
connectionFactory, sendQueue, responseQueue,
serializationProvider, Collections.EMPTY_SET, JaxbSerializationProvider.JMS_SERIALIZATION_TYPE,
5 * 1000);
long taskId = taskSumList.get(0).getId();
}
// @formatter:off
public static Object sendJmsCommand( Command command,
String connUser, String connPassword,
String userName, String password, String deploymentId, Long processInstanceId,
ConnectionFactory factory, Queue sendQueue, Queue responseQueue,
SerializationProvider serializationProvider, Set<Class<?>> extraJaxbClasses, int serializationType,
long timeoutInMillisecs ) {
// @formatter:on
if( deploymentId == null && !(command instanceof TaskCommand || command instanceof AuditCommand) ) {
throw new MissingRequiredInfoException("A deployment id is required when sending commands involving the KieSession.");
}
JaxbCommandsRequest req;
if( command instanceof AuditCommand ) {
req = new JaxbCommandsRequest(command);
} else {
req = new JaxbCommandsRequest(deploymentId, command);
}
req.setProcessInstanceId(processInstanceId);
req.setUser(userName);
req.setVersion(VERSION);
Connection connection = null;
Session session = null;
JaxbCommandsResponse cmdResponse = null;
String corrId = UUID.randomUUID().toString();
String selector = "JMSCorrelationID = '" + corrId + "'";
try {
// setup
MessageProducer producer;
MessageConsumer consumer;
try {
if( password != null ) {
connection = factory.createConnection(connUser, connPassword);
} else {
connection = factory.createConnection();
}
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(sendQueue);
consumer = session.createConsumer(responseQueue, selector);
connection.start();
} catch( JMSException jmse ) {
throw new RemoteCommunicationException("Unable to setup a JMS connection.", jmse);
}
// Create msg
TextMessage textMsg;
try {
// serialize request
String xmlStr = serializationProvider.serialize(req);
textMsg = session.createTextMessage(xmlStr);
// set properties
// 1. corr id
textMsg.setJMSCorrelationID(corrId);
// 2. serialization info
textMsg.setIntProperty(SERIALIZATION_TYPE_PROPERTY_NAME, serializationType);
if( extraJaxbClasses != null && !extraJaxbClasses.isEmpty() ) {
if( deploymentId == null ) {
throw new MissingRequiredInfoException(
"Deserialization of parameter classes requires a deployment id, which has not been configured.");
}
textMsg.setStringProperty(DEPLOYMENT_ID_PROPERTY_NAME, deploymentId);
}
// 3. user/pass for task operations
boolean isTaskCommand = (command instanceof TaskCommand);
if( isTaskCommand ) {
if( userName == null ) {
throw new RemoteCommunicationException(
"A user name is required when sending task operation requests via JMS");
}
if( password == null ) {
throw new RemoteCommunicationException(
"A password is required when sending task operation requests via JMS");
}
textMsg.setStringProperty("username", userName);
textMsg.setStringProperty("password", password);
}
// 4. process instance id
} catch( JMSException jmse ) {
throw new RemoteCommunicationException("Unable to create and fill a JMS message.", jmse);
} catch( SerializationException se ) {
throw new RemoteCommunicationException("Unable to deserialze JMS message.", se.getCause());
}
// send
try {
producer.send(textMsg);
} catch( JMSException jmse ) {
throw new RemoteCommunicationException("Unable to send a JMS message.", jmse);
}
// receive
Message response;
try {
response = consumer.receive(timeoutInMillisecs);
} catch( JMSException jmse ) {
throw new RemoteCommunicationException("Unable to receive or retrieve the JMS response.", jmse);
}
if( response == null ) {
logger.warn("Response is empty");
return null;
}
// extract response
assert response != null: "Response is empty.";
try {
String xmlStr = ((TextMessage) response).getText();
cmdResponse = (JaxbCommandsResponse) serializationProvider.deserialize(xmlStr);
} catch( JMSException jmse ) {
throw new RemoteCommunicationException("Unable to extract " + JaxbCommandsResponse.class.getSimpleName()
+ " instance from JMS response.", jmse);
} catch( SerializationException se ) {
throw new RemoteCommunicationException("Unable to extract " + JaxbCommandsResponse.class.getSimpleName()
+ " instance from JMS response.", se.getCause());
}
assert cmdResponse != null: "Jaxb Cmd Response was null!";
} finally {
if( connection != null ) {
try {
connection.close();
if( session != null ) {
session.close();
}
} catch( JMSException jmse ) {
logger.warn("Unable to close connection or session!", jmse);
}
}
}
String version = cmdResponse.getVersion();
if( version == null ) {
version = "pre-6.0.3";
}
if( !version.equals(VERSION) ) {
logger.info("Response received from server version [{}] while client is version [{}]! This may cause problems.",
version, VERSION);
}
List<JaxbCommandResponse<?>> responses = cmdResponse.getResponses();
if( responses.size() > 0 ) {
JaxbCommandResponse<?> response = responses.get(0);
if( response instanceof JaxbExceptionResponse ) {
JaxbExceptionResponse exceptionResponse = (JaxbExceptionResponse) response;
throw new RemoteApiException(exceptionResponse.getMessage());
} else {
return response.getResult();
}
} else {
assert responses.size() == 0: "There should only be 1 response, not " + responses.size() + ", returned by a command!";
return null;
}
}
}
These classes can all be found in the | |
The | |
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. |
Except for the Execute calls, all other REST calls described below can use either JAXB or JSON.
All REST calls, unless otherwise specified, use JAXB serialization.
When using JSON, make sure to add the JSON media type ("application/json"
) to the
ACCEPT
header of your REST call.
The user-defined class satisfy the following in order to be property serialized and deserialized:
Furthermore, the following usage of JAXB annotations is recommended:
javax.xml.bind.annotation.XmlAccessorType
annotation
specifying that fields should be used, (javax.xml.bind.annotation.XmlAccessType.FIELD
). This
also means that you should annotate the fields (instead of the getter or setter methods)
with @XmlElement
or @XmlAttribute
annotations.@XmlElement
or @XmlAttribute
annotations should also be annotated with
javax.xml.bind.annotation.XmlSchemaType
annotations specifying the type of the field, even
if the fields contain primitive values.java.lang.Integer
class for
storing an integer value, and not the int
class. This way it will always be obvious if the
field is storing a value.Long
or
String
) or otherwise be objects that satisfy the same requiremends in this list (correct
usage of JAXB annotations and a no-arg constructor).The first page is always page 1 (as opposed to page "0").
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.16. 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 |
|
Returns a |
|
Returns a |