将Camunda嵌入到现有的Java应用程序中 [英] Embedding Camunda into an existing Java application

查看:169
本文介绍了将Camunda嵌入到现有的Java应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提取了Camunda的最新映像,并在其自己的docker容器中运行了Camunda.我已将一个dmn上传到Camunda Cockpit,并且可以进行Rest调用以从已上传到Camunda Cockpit的决策表中获取数据.但是,我不想依靠Camunda独立运行.我有一个现有的大型应用程序(在其自己的docker容器中运行的微服务),我想将Camunda嵌入我的微服务(使用Osgi,Java,Docker,Maven等).有人可以指导我吗?

I have pulled the Camunda latest image and running Camunda in it's own docker container. I have a dmn uploaded to Camunda Cockpit and I am able to make Rest calls to get data from the decision table that I have uploaded to the Camunda Cockpit. However, I do not want to depend on Camunda running independently. I have an existing huge application(a micro-service running in it's own docker container) and I want to embed Camunda into my micro-service (that uses Osgi, Java, Docker, Maven, etc.). Can someone please guide me with this?

推荐答案

对于Spring Boot微服务,您可以将所需的启动程序和配置文件添加到您的部署中,应该可以使用.参见例如 https://start.camunda.com/即可获取所需的一切.然后,您可以通过Java API或REST(如果包含入门程序)访问Camunda.

For a Spring Boot micro service you can add the required starter and config files to your deployment and should be good to go. See e.g. https://start.camunda.com/ to get everything you need. You can then access Camunda via Java API or REST (if starter was included).

如果您没有在Spring Boot环境中运行,那么引导Camunda的方式可能会有所不同.在普通的Java中,无需使用任何容器就可以满足以下要求:

If you do not run in a Spring Boot environment then the way of bootstrapping Camunda may differ. In plain Java, without any container usage it would be along those lines:

    ProcessEngine processEngine = ProcessEngineConfiguration
        .createStandaloneProcessEngineConfiguration()
        .setJdbcUrl("jdbc:h2:./camunda-db/process-engine;DB_CLOSE_DELAY=1000")
        .setDatabaseSchemaUpdate("true")
        .setJobExecutorActivate(true)
        .buildProcessEngine();
    
    processEngine.getRepositoryService()
        .createDeployment()
        .addClasspathResource("myProcess.bpmn")
        .deploy();
        
    ProcessInstance pi = processEngine.getRuntimeService()
        .startProcessInstanceByKey("myProcess");

在标准Spring环境中,您将通过加载上下文来引导引擎:

In a standard Spring environment you would bootstrap the engine by loading the context:

    ClassPathXmlApplicationContext applicationContext = 
        new ClassPathXmlApplicationContext("/spring-context.xml");
    ProcessEngine processEngine = (ProcessEngine) applicationContext.getBean("processEngine");
        
    processEngine.getRepositoryService()
        .createDeployment()
        .addClasspathResource("myProcess.bpmn")
        .deploy();

另请参阅: https://docs.camunda.org/manual/latest/user-guide/process-engine/process-engine-bootstrapping/

https://docs.camunda.org/get-started/快速启动/安装/

根据评论进行更新:

Camunda OSGI支持的描述如下: https://github.com/camunda/camunda-bpm-platform-osgi

The Camunda OSGI support is described here: https://github.com/camunda/camunda-bpm-platform-osgi

您需要将项目升级到最新版本,由于该版本保持兼容,因此这可能不是很大的工作.

You would need to upgrade the project to a more recent version, which is likely not a huge effort as the version have remained compatible.

(我也鼓励您考虑将微服务迁移到Spring Boot.复杂性,市场上可用的知识,支持生命周期,..)

(I would also encourage you to consider migrating the micro service to Spring Boot instead. Complexity, available knowledge in the market, support lifetime,..)

这篇关于将Camunda嵌入到现有的Java应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆