This content has been marked as final.
Show 3 replies
-
1. Re: How to start process with correlation key using rest commands?
swiderski.maciej Mar 20, 2015 3:01 AM (in response to melissa.ferenal)1 of 1 people found this helpfulyou should use /runtime/{deploymentId}/execute end point and then use StartCorrelatedProcessCommand to actually start it. I'd recommend looking at Remote Java API as it can do that for you. If you need to use end point directly then best would be to once use the Remote Java API to see the payload of the message that is generated - it will be xml of the command.
HTH
-
2. Re: How to start process with correlation key using rest commands?
melissa.ferenal Mar 24, 2015 7:10 PM (in response to swiderski.maciej)Got it working.. Thanks...
public static List<JaxbCommandResponse<?>> executeCommand(List<Command> commands) throws Exception { URL address = new URL(appUrl +"/rest/execute"); ClientRequest restRequest = createRequest(address); JaxbCommandsRequest commandMessage = new JaxbCommandsRequest(); commandMessage.setDeploymentId(deploymentId); commandMessage.setCommands(commands); String body = convertJaxbObjectToString(commandMessage); restRequest.body(MediaType.APPLICATION_XML, body); ClientResponse<JaxbCommandsResponse> responseObj = restRequest .post(JaxbCommandsResponse.class); // checkResponse(responseObj); JaxbCommandsResponse cmdsResp = responseObj.getEntity(); return cmdsResp.getResponses(); } public static void main(String args[]) { StartProcessTest s = new StartProcessTest(); List<Command> list = new ArrayList<Command>(); CorrelationKeyFactory factory = KieInternalServices.Factory.get().newCorrelationKeyFactory(); List<String> keys = new ArrayList<String>(); keys.add("str1"); keys.add("str2"); CorrelationKey key = factory.newCorrelationKey(keys); list.add(new StartCorrelatedProcessCommand( "Sub_Process_Test.TestConfirmOrder", key)); try { s.executeCommand(list); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("------Done-----"); }
-
3. Re: How to start process with correlation key using rest commands?
swiderski.maciej Mar 25, 2015 12:35 PM (in response to melissa.ferenal)in case you'd like to use directly Remote Java API provided by jBPM you can do as follows:
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId("org.jbpm:HR:1.0") .addUrl(deploymentUrl) .addUserName("user") .addPassword("password") .addTimeout(5000) .build(); Map<String, Object> parameters = new HashMap<String, Object>(); String inputData = "john"; parameters.put("name", inputData); StartCorrelatedProcessCommand cmd = new StartCorrelatedProcessCommand(); cmd.setCorrelationKey("test"); cmd.setProcessId("hiring"); cmd.setParameter(ConversionUtil.convertMapToJaxbStringObjectPairArray(parameters)); ProcessInstance processInstance = engine.getKieSession().execute(cmd);
to start hiring process from HR example project.
Just for completeness.