Java, J2SE, J2ME, J2EE, ANDROID, JQUERY, JAVA SCRIPT, JSP, SERVLET, Collection Framework, Java Generics, C, C++
Saturday, June 2, 2018
Friday, May 25, 2018
start Camunda Process using Native API
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ProcessHandler {
private static final String HTTP_LOCALHOST_8080_APP_REST = "http://localhost:8080/mycamunda/rest";
private static final Logger logger = LoggerFactory.getLogger(ProcessHandler.class);
@Autowired
private RuntimeService runtimeService;
private ProcessInstance processInstance;
public boolean startProcess(String processInstanceKey) {
logger.debug("Called method startProcess() ");
try {
logger.debug("Starting process for Key: " + processInstanceKey);
processInstance = runtimeService.startProcessInstanceByKey(processInstanceKey);
logger.debug("Process Started Successfully");
} catch (Exception ex) {
logger.debug("Error while starting the process. Reason: " + ex.getMessage());
return false;
}
return true;
}
}
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ProcessHandler {
private static final String HTTP_LOCALHOST_8080_APP_REST = "http://localhost:8080/mycamunda/rest";
private static final Logger logger = LoggerFactory.getLogger(ProcessHandler.class);
@Autowired
private RuntimeService runtimeService;
private ProcessInstance processInstance;
public boolean startProcess(String processInstanceKey) {
logger.debug("Called method startProcess() ");
try {
logger.debug("Starting process for Key: " + processInstanceKey);
processInstance = runtimeService.startProcessInstanceByKey(processInstanceKey);
logger.debug("Process Started Successfully");
} catch (Exception ex) {
logger.debug("Error while starting the process. Reason: " + ex.getMessage());
return false;
}
return true;
}
}
Start Process using CAMUND REST API
import java.util.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/AppContextName/rest/process-definition/key/"+processInstanceKey+"/start");
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes());
// admin:admin is username:password
logger.info("encoding: "+encoding);
HttpEntity entity = new StringEntity("{}");
request.setEntity(entity);
request.setHeader("Authorization", "Basic " + encoding);
request.addHeader("Content-Type", "application/json");
HttpResponse response = client.execute(request);
System.out.println("Response String: "+response.toString());
System.out.println("Response Code: "+response.getStatusLine().getStatusCode());
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/AppContextName/rest/process-definition/key/"+processInstanceKey+"/start");
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes());
// admin:admin is username:password
logger.info("encoding: "+encoding);
HttpEntity entity = new StringEntity("{}");
request.setEntity(entity);
request.setHeader("Authorization", "Basic " + encoding);
request.addHeader("Content-Type", "application/json");
HttpResponse response = client.execute(request);
System.out.println("Response String: "+response.toString());
System.out.println("Response Code: "+response.getStatusLine().getStatusCode());
Subscribe to:
Posts (Atom)
Scrum and Scrum master
Scrum Scrum is a framework which helps a team to work together. It is like a rugby team (the scrum name comes from rugby game). Scrum enco...
-
Docker: Docker is a tool/system/framework designed to make it easier to create, deploy, and run applications by using containers. Contain...
-
var beanPropertyArray = []; columnData = { "1": "One", "2": "Two", ...
-
Whenever an object of a POJO class is created then it will be in the Transient state An object in a Transient state doesn’t represent any...