通过 Spring 引导部署 Zeebe

Zeebe deployment via Spring Boot

我想通过 Spring Boot Zeebe starter

部署多个 BPMN 文件

这就是我当前指定部署的方式

@ZeebeDeployment(classPathResource = "customerFlow.bpmn")

关于如何部署两个以上的 bpmn 文件有什么建议吗?

参考:https://github.com/zeebe-io/spring-zeebe


编辑:

我确实尝试过这样的事情

@Autowired private ZeebeClient zeebeClient;

@PostConstruct
public void deploy(){
    final DeploymentEvent deployment = zeebeClient.newDeployCommand()
            .addResourceFromClasspath("customerFlow.bpmn")
            .send()
            .join();
}

收到以下错误:

Caused by: java.lang.IllegalStateException: delegate is not running!
    at io.zeebe.spring.util.ZeebeAutoStartUpLifecycle.get(ZeebeAutoStartUpLifecycle.java:38)
    at io.zeebe.spring.client.ZeebeClientLifecycle.newDeployCommand(ZeebeClientLifecycle.java:71)
    at com.lendingkart.flows.app.App.deploy(App.java:51)

您可以在DeploymentAnnoation中交出资源列表:

@ZeebeDeployment(classPathResources = {"customerFlow.bpmn", "secondFile.bpmn"})

我刚刚更新了自述文件以反映这一点:

https://github.com/zeebe-io/spring-zeebe/blob/master/README.md#deploy-workflow-models

这似乎适用于我的情况

@Component
public class ZeebeDeployer {

    @Value("${zeebe.client.broker.contactPoint}")
    private String zeebeBroker;

    private static Logger logger = LoggerFactory.getLogger(ZeebeDeployer.class);

    @PostConstruct
    public void deploy(){
        try(ZeebeClient client = ZeebeClient.newClientBuilder()
                    // change the contact point if needed
                    .brokerContactPoint(zeebeBroker)
                    .usePlaintext()
                    .build();){

            client.newDeployCommand()
                .addResourceFromClasspath("abc.bpmn")
                .addResourceFromClasspath("xyz.bpmn")
                .send()
                .join();
        }catch (Exception e){
            //Todo: better to throw custom exception here
            logger.error("Zeebe deployment failed {}", e.getMessage(), e);
        }
    }
}