camunda / camunda-bpm-spring-boot-starter

Camunda BPM bootified!
Apache License 2.0
326 stars 161 forks source link

Question: Spring Boot starter with shared engine? #156

Closed miwoe closed 7 years ago

miwoe commented 7 years ago

Hi,

I am currently trying to deploy a Spring Boot application with a shared process engine on a tomcat. I thought I have the solution, but it seems that I have two different application contexts running. I cannot autowire dependencies like RuntimeService.

Is there any example available for using Spring Boot with a shared engine on a servlet container?

Best Regards, Michael

jangalinski commented 7 years ago

Hm. You probably know the war example https://github.com/camunda/camunda-bpm-spring-boot-starter/tree/master/examples/example-war Buts thats still using an embedded engine. I wonder why I would want to use spring boot in a shared engine scenario anyway. Could you please elaborate what problem you are trying to solve? I mean if the engine is configured via platform.xml anyway, a normal engine-spring application would be enough, this extension mainly deals with configuring/starting and deploying the engine ...

miwoe commented 7 years ago

We are using Camunda in a layered microservice context and some services are controlled by BPM process. As the BPM process is invoking some other BPM processes of other domains, we preferred a shared engine with a central Camunda installation and its central cockpit and administration tools.

I have solved the problem with the examples by propagating the process engine in the Spring Context:

    @Bean
    public ProcessEngineService getProcessEngineService() {
        return BpmPlatform.getProcessEngineService();
    }

    @Bean
    public ProcessEngine getProcessEngine() {
        return this.getProcessEngineService().getDefaultProcessEngine();
    }
thanigachalamp commented 3 years ago

Hi,

I am also using Camunda in a layered microservice context and some services are controlled by BPM process. As the BPM process is invoking some other BPM processes of other domains, we preferred a shared engine with a central Camunda installation and its central cockpit and administration tools.

I have followed above steps, but always process engine is null this.processEngineService().getDefaultProcessEngine().

Listed out the steps:

  1. Downloaded Tomcat
  2. Downloaded camunda-webapp-tomcat-standalone-7.14.0.war, unzip and drop it in the webapps
  3. My own spring boot application is build and when i tried to deployed into same tomcat, always got null processEngineService().getDefaultProcessEngine()

Please find the sample code: @Bean public ProcessEngineService processEngineService() { return BpmPlatform.getProcessEngineService(); } @Bean(destroyMethod = "") public ProcessEngine processEngine(){ ProcessEngine processEngine = this.processEngineService().getDefaultProcessEngine(); System.out.println(" Process engine is successfully created "+processEngine); return processEngine; } @Bean public SpringProcessApplication processApplication() { return new SpringProcessApplication(); }

org.camunda.bpm camunda-engine provided
<dependency>
  <groupId>org.camunda.bpm</groupId>
  <artifactId>camunda-engine-spring</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
</dependency>
<dependency>
  <groupId>org.apache.tomcat.embed</groupId>
  <artifactId>tomcat-embed-jasper</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-tomcat</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Please help me to resolve