- 创建流程图payment.bpmn
- 创建Maven项目实现Java应用程序
- 启动Camunda Cloud Run
- 部署流程并启动流程实例
- 参考资料
- Start Event
Name:收到付款请求
- Service Task
Name:xyk收款
将该任务设置为Service Task,然后将Implementation设置为External,Topic:charge-card。
- End Event
Name:收到付款
- payment.bpmn
点击任意空白处,设置流程图的Id、Name,勾选Executable。
Id:payment-retrieval
Name:收款
最后将将文件另存为payment.bpmn。
pom文件中添加依赖,pom.xml的内容如下,
4.0.0 org.camunda.bpm.getstarted charge-card-worker1.0-SNAPSHOT 8 8 7.16.0 org.camunda.bpm camunda-external-task-client${camunda.external-task-client.version} org.slf4j slf4j-simple1.6.1 javax.xml.bind jaxb-api2.3.1
创建启动类org.camunda.bpm.getstarted.chargecard.ChargeCardWorker,内容如下,
package org.camunda.bpm.getstarted.chargecard; import org.camunda.bpm.client.ExternalTaskClient; import java.util.logging.Logger; public class ChargeCardWorker { private final static Logger LOGGER = Logger.getLogger(ChargeCardWorker.class.getName()); public static void main(String[] args) { ExternalTaskClient client = ExternalTaskClient.create().baseUrl("http://localhost:8080/engine-rest") .asyncResponseTimeout(10000) .build(); client.subscribe("charge-card").lockDuration(1000) .handler((externalTask, externalTaskService) -> { String item = (String) externalTask.getVariable("item"); Long amount = (Long) externalTask.getVariable("amount"); LOGGER.info( "Charging credit card with an amount of '"+amount+"€' for the item '"+item+"'..." ); externalTaskService.complete(externalTask); }).open(); } }
运行ChargeCardWorker#main,启动Java应用。
https://docs.camunda.org/get-started/quick-start/service-task/
https://docs.camunda.org/get-started/quick-start/deploy/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)