I am working on a Camunda BPM Spring Boot Application. The application reads messages from rabbitmq queue using Spring Cloud Stream. Once the message is received, the application invokes a process instance in Camunda.
If there are messages already in the rabbitmq queue during application startup, the cloud stream listener starts reading messages even before Camunda is initialized.
Is it possible to stop the cloud stream listener from listening to the queue till some event is fired - in this case PostDeployEvent.
I have created a sample application for reference https://github.com/kpkurian/spring-cloud-stream-camunda
Thanks!!
As suggested by @OlegZhurakousky
Issue
RuntimeService is autowired, and by the time application is started it the assumption is that all services, beans etc are fully initialized. If it is still going through the process of initialization and startup then it is not properly implemented from Spring idioms perspective.
Solution
wrap RuntimeService with a custom Lifecycle implementation which would not return until its start() method is executed ensuring that RuntmeService is ready to go.
I have implemented this in the sample github application