Saturday, June 2, 2018

How to Run maven project on tomcat and change tomcat port while running using maven



Set following command in the Goals:

-Dmaven.tomcat.port=8181 tomcat:run



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


}

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());

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