spring-bootcamundazeebe

Zeebe deployment via Spring Boot


I want to deploy multiple BPMN files via Spring Boot Zeebe starter

This is how I am currently specifying my deployment

@ZeebeDeployment(classPathResource = "customerFlow.bpmn")

Any suggestion on how to deploy more than two bpmn files?

Reference : https://github.com/zeebe-io/spring-zeebe


Edit:

I did try something like this

@Autowired private ZeebeClient zeebeClient;

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

Received following error:

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)

Solution

  • This seems to be working for my case

    @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);
            }
        }
    }