Tomcat does not start after change to bpmn file

Hi there!

I’ve a very strange issue with Camunda running in a Spring Boot application. Up to now I did not require a running Tomcat (except the times when working with Camunda Cockpit). Now I tried to use the Tomcat server for monitoring purposes as well, but found out it was not reachable anymore.

I tackled it down to this change:

    <bpmn:participant id="Participant_JobFetcher" name="Job Fetcher" processRef="Process_JobFetcher" />
  </bpmn:collaboration>
  <bpmn:process id="Process_JobFetcher" name="Job Fetcher" isExecutable="true" camunda:versionTag="1">
   <bpmn:startEvent id="StartEvent_JobFetcher" name="Start Job Fetcher" camunda:asyncBefore="true" camunda:exclusive="false">
      <bpmn:outgoing>SequenceFlow_14pz92v</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="Task_JobFetcher" name="Wait for next job" camunda:delegateExpression="${jobFetcherDelegate}">

to

    <bpmn:participant id="Participant_JobFetcher" name="Job Fetcher" processRef="Process_JobFetcher" />
  </bpmn:collaboration>
  <bpmn:process id="Process_JobFetcher" name="Job Fetcher" isExecutable="true" camunda:versionTag="1">
   <bpmn:startEvent id="StartEvent_JobFetcher" name="Start Job Fetcher">
      <bpmn:outgoing>SequenceFlow_14pz92v</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="Task_JobFetcher" name="Wait for next job" camunda:delegateExpression="${jobFetcherDelegate}">

Only

camunda:asyncBefore=“true” camunda:exclusive=“false”

was removed.

This appears totally weired to me. I didn’t expect a change to the bpmn file to cause problems when starting up the Tomcat server. In the Spring Boot logs I canot see

[TomcatWebServer] Tomcat started on port(s): 8080 (http) with context path ‘’
anymore. There are no errors or warnings in the log.

Does anyone have an idea why this happens?

Best regards,
cd_

Anyone an idea? Has anyone had this or something similar before? Or perhaps suggestions how to find out what’s going wrong?

I agree. It is very unlikely that this causes the problem.

If you can share example code and exact steps to reproduce it, I am happy to give it a look. Other than that, try to figure out if any Tomcat log files are written (or if this can be configured in the Spring boot environment).

Cheers,
Thorben

I haven’t reduced my application to a minimal sample showing the problem yet. But I’ve made some progress on finding the cause. I’m not sure how to fix it properly.

Basically it’s due to having a call to

this.mCamundaRtService.startProcessInstanceByKey(this.mCamundaProcessName);
in a method of my Camunda-configuration class for Spring Boot which is annotated with @PostConstruct.

Effectively the call to startProcessInstanceByKey blocks until the process ends. The process is designed to be an endless loop (probably the first design error). Thus the method blocks endlessly. This blocks Spring to fully start up und thus keeps the Tomcat server from staring up.

The second error might be that the process is started up in the @PostConstruct annotated method instead of relying on Camunda magic to start processes. Basically his kind of starting the process has been done because the application makes use of two separate processes: a) a process waiting for new jobs to arrive (via database or message queue) b) a process which works on each arrived order. Process b) receives a message from process a) to start its work, after that has been done, the process terminates with an Terminate End Event. Is this against Camunda best practises?

Best regards,
cd_

This is indeed not a good idea because eventually the process engine’s transaction will time out. Make sure to include wait states in the process, such as asynchronous continuations. Maybe a Camunda-managed process is not a good tool for this sort of thing (polling message queue) at all. Maybe something like Apache Camel and the Camunda integration (GitHub - camunda-community-hub/camunda-platform-7-camel: Community Extension to add Apache Camel support for Camunda Platform 7) are a better solution.

That sounds fine to me and should work once you have resolved the infinite loop.

Ok, I try to get the background knowledge for that… I’ll read https://docs.camunda.org/manual/7.5/user-guide/process-engine/transactions-in-processes/ Anything else I should dive into?

Best regards,
cd_

Hi cd_,

That should be a good starting point. Feel free to ask if you have remaining questions and we can point you to useful resources.

Cheers,
Thorben

I think I’ve a working solution. My job fetching process now looks like this:

2018-05-29%2014_04_17-Camunda%20Modeler

The Start Job Fetcher event is marked as async before and exclusive. The timer is set to 1 sec interval.

As far as I can see Camunda does not think the process were stalled and keeps executing it within a single, not changing thread. Tomcat is started up properly as well (besides the rest of the Spring magic).

What’s a bit strange, is that delays of less than 5 seconds leads to actually no delay, Camunda keeps firing the activities. If found something similar in Fast repeating Timer Event not working properly, but cannot follow the argumentation there. Could you try to elaborate?

Second question: From my understanding of the docs I thought that setting the exclusive attribute effectively prevents Camunda from spawning up more than one thread to handle this workload. But I could not confirm this in my tests. When I made the job fetching take 20 seconds whilest setting the lockTimeInMillis to 10 seconds, Camunda spawned up new threads. So, there’s something else to it – can you please explain this to me?

Best regards,
cd_