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;
    }


}

No comments:

Post a Comment

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...