flowable使用mongodb

摘要:flowable使用mongodb,flowable集成mongodb,flowable如何使用mongodb

Flowable为啥看上了MongoDB

Activiti差不多2013年就有了,Flowable差不多2016年就有了。为啥期间没有使用MongoDB。那MongoDB是啥时候出现的。2009年2月开源数据库MongoDB 1.0正式面世。

2018年6月, MongoDB推出ACID事务支持,成为第一个支持强事务的NoSQL数据库

既然支持了ACID事务,于是乎Flowable开始默认集成了MongoDB。

MongoDB下载

MongoDB下载地址:https://www.mongodb.com/download-center/community。

MongoDB启动

./mongod --port 27017 --bind_ip_all --dbpath ../
 ./mongo

Flowable MongoDB包

在pom.xml中添加如下依赖

Flowable MongoDB使用

  ProcessEngine processEngine = new MongoDbProcessEngineConfiguration()
            .setServerAddresses(Arrays.asList(new ServerAddress("127.0.0.1", 27017)))
            .setDisableIdmEngine(true)
            .buildProcessEngine();
        System.out.println(processEngine);

执行上述代码之后,会生成如下的几个document.

 

 

 

 

 

 

Flowable是一个功能强大的业务流程框架,它使用了Java、Spring Framework、MyBatis和Activiti等技术。通过Flowable,我们可以建模、执行和监控业务流程。下面是一个使用Flowable的示例: ```java import org.flowable.engine.ProcessEngine; import org.flowable.engine.ProcessEngineConfiguration; import org.flowable.engine.RepositoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; import org.flowable.engine.repository.Deployment; import org.flowable.engine.runtime.ProcessInstance; import org.flowable.task.api.Task; public class FlowableExample { public static void main(String[] args) { // 创建流程引擎 ProcessEngineConfiguration cfg = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration(); ProcessEngine processEngine = cfg.buildProcessEngine(); // 部署流程定义 RepositoryService repositoryService = processEngine.getRepositoryService(); Deployment deployment = repositoryService.createDeployment() .addClasspathResource("my-process.bpmn20.xml") .deploy(); // 启动流程实例 RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process"); // 处理任务 TaskService taskService = processEngine.getTaskService(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); System.out.println("当前任务:" + task.getName()); // 完成任务 taskService.complete(task.getId()); // 验证流程是否结束 ProcessInstance finishedInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult(); System.out.println("流程是否结束:" + (finishedInstance == null)); // 关闭流程引擎 processEngine.close(); processEngine = null; } } ``` 这个示例演示了Flowable的基本使用流程,包括创建流程引擎、部署流程定义、启动流程实例、处理任务和验证流程是否结束。你可以根据自己的需求进行进一步的定制和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值