So, I have an spring boot 1.5.8 application using shared runtime. Like the example below:
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan("org.my.project")
@ProcessApplication
class MyApplication
In my scenario, I have an API used by some microservices and business people, with 2 endpoints, one to deploy a new camunda bpmn and one to start a new process with this deployed file.
I’m trying to test these 2 endpoints using spring mockMvc helper and I’m stumbling in a very strange error. All my test scenarios are isolated, so each test has to create a new deploy and then start it. Here is where the problem happens, for some reason, when my test sends a deploy, everything works fine, camunda accepts my deploy, and even returns the deployed information, but when the second request kicks in, to start this new deployed bpmn, camunda doesn’t find it, instead it throws the below error:
no processes deployed with key 'myBusinessKey': processDefinition is null
Which shouldn’t happend, because a deploy happened a few seconds before…
Looking at the stack trace, I noticed that during my test, when trying to start a new process, camunda looked in some kind of internal deployment persistence cache, and looking in the documentation I found a very short reference about it.
https://docs.camunda.org/manual/7.7/user-guide/process-engine/deployment-cache/
The link above doesn’t say how to disable this cache or how to flush it.
So, if I had to guess what was happening internally in camunda, I would say one of the following behaviors is happening:
- There is some cache configuration missing
- There is some kind of cache flush that I manually need to execute between creating a deploy and starting it
- There is some kind of delay after deploy, and I would have to wait a few seconds before starting a new process
- Camunda is only looking in this deployment cache and If not found, not trying to find it too in relational database
- Camunda automatically detects that its being executed in a test context and somehow change its behavior.
Any thoughts on this?
P.S: A important thing to take into consideration is that if I enable auto deploy, by putting all my .bpmn files inside my project and let camunda by itself deploy these files, then for some obscure reason, when I execute the process test, it works, camunda does find the files and is able to start a process instance, so the error only happens when using programmatically deploys
I will also leave here the code I using to deploy a file programmatically and to start it.
Code to deploy (written in kotlin):
processEngine.repositoryService
.createDeployment()
.addInputStream(file.originalFilename, file.inputStream)
.enableDuplicateFiltering(true)
.deploy()
Code to start a instance (written in kotlin):
runtimeService
.startProcessInstanceByKey(processDefinitionKey, myBusinessKey, variables)
.id
I really hope someone could help me with this.
Thanks in advance.