Problem with parallel execution of multiple processes

I have a simple bpmn process, which is executing in cycle. This is just an example, for a process that needs to be executed repeatedly.


What I want to achieve is to have a jar file (Spring boot project) which is running in background. In external folder named processes which is outside of the default path of the project I want to be able to put bpmn processes that will be deployed automatically in the running jar file. For that reason I use a folder listener.
It works when I am trying with one process, but when I put other processes in the folder they never get deployed. I also cannot delete the process that is being run from the folder in order to suspend it. Here is my code for the folder listener:

Path dir = Paths.get("…\eclipse-workspace\test\test");

			WatchService watcher = dir.getFileSystem().newWatchService();
			dir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
			for(;;) {
				try {
					WatchKey watckKey = watcher.take();
					List<WatchEvent<?>> events = watckKey.pollEvents();
					for (WatchEvent<?> event : events) {

						DeploymentBuilder db = repositoryService.createDeployment();

						if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE) {
							System.out.println("Created: " + event.context().toString());

							db.addInputStream(event.context().toString(), new FileInputStream(new File("test/" + event.context().toString())));

						} else if (event.kind() == StandardWatchEventKinds.ENTRY_DELETE) {
							System.out.println("Delete: " + event.context().toString());

						} else if (event.kind() == StandardWatchEventKinds.ENTRY_MODIFY) {
							System.out.println("Modify: " + event.context().toString());

When the first process starts to run with this line of code:


It never gets to the next line of code, it gets stuck in the runtimeService, probably waiting for the process to finish.
Is there a possibility to run more process instances simultaneously? Can you explain the Flowable behavior in this situation?

Thank you in advance,

I don’t know if this will help you at all, but:

  1. Is it possible your process in in an endless loop? (gateway to script task)
  2. Have you tried setting your script task to asynchronous?

maudrid, thank you for your reply. Yes the process is in an endless loop, and I’ve already fixed it with setting the script task to asynchronous.