Loop asynchronous problem

Hello i am wondering if someone could help me please.
My problem as follows:
I have this processes interacting with each other, also a loop is included like it is stated in the docs. (P1-Model.bpmn, P2-Model.bpmn, P3-Model.bpmn). I always start the process P1-Model as first and then the control flow should be handled by other partners throwing send tasks.

At the end of the loop, i.e. when P2 sends the process variable (c) to the other two partners (P1 and P3).
Here it is the case that P2 sends the process variable (c with value: false) to P1 after the BRT, he (P1) gets it and goes straight on in his model, so fast that he is directly back at the control flow transfer to P2 (GREEN), but P2 is not ready yet because he sends process variable (c with value: false) to P3 (RED).
In order to execute the request successfully, it would already have to be in the receive task after the split Gtw (BLUE).

If the process variable “c” has the value “false” it follows the “no” sequence path otherwise if it is “true” it follows the “yes” path to the end event.

Of course I use Asynchronous Continuation for the Send and Receive tasks (tried before and after and both), so this should work normally, because he saves the request in the database of Camunda but due to the loop this does not behave as it should and he just throws a correlation error that he can not correlate the specified message to any Receive task.

Any advice what i can do here?

Many thanks
Sebastian

I recommend changing your model P2: You can add flexibility to receive the message (P1)[P2] at different point in times. One option would be an event subprocess:

1 Like

Thank you. Indeed, this would be possible but i am wondering is there no chance to build this only with send and receive tasks so no other events. ?

I am also facing an error directly on the beginning.
Here P1 would start and execute activity “T1 [P1]”, then the control flow is passed to P3.
P3 has a message start event and receives the message from P1. So P3 starts and now he also has to send a message start request to P2. Now to the problem.
P1 goes directly to the split XOR node and then it also executes the activity “T2 [P1]” and passes the control flow to P2 (GREEN). However, P1 is so fast that P2 is not yet started by the control flow transfer of P3 and thus P1 throws an error (http 400) because P2 is not yet at the correct Receive Task (also correlation error).

You created a process choreography that is not locally enforceable. This means, without additional communication or other fundamental changes to the processes, we cannot guarantee that messages are sent and received in the desired order. More precisely: When your processes loop, P1 cannot know whether P2 is ready or not.

Let’s address one problem after the other:
Have you added an asynchronous before to the message start events? This may resolve the first issue.

I think, we have to change the models to resolve the second issue:
Either switch the order of Send({c} P1)[P2] and Send({c} P3)[P2] or make sure that you are ready. If you do not want to use events, you can do the following:

1 Like

Oh ok i see, yes you a right…

To the first problem:
Yes i have had it already before (before, after or both) but nothing works. The mismatchCorrelation error occurs anyway. I see that both messages are sended in the same second. The message start event as well as the next message within the loop, but i cannot correlate somehow as the process P2 is not alive yet. (i assume)

Second problem:
This looks also not to bad, i tried it, it runs many iterations but at some point it also ends in correlation error. What i have done for that is, to send a message again if i get a http 400 error on sending side. Now it works but it is more or less a dirty solution. I want one with no errors at all.

For switching positions of the send tasks would erase all the problems, yes you are right, but i cannot gurantee that these processes will always be generated in the right order as there is some automatismn behind.

I have tried this process with an additional event subprocess like you proposed.

But the (1st) problem when P2 is not active yet makes some troubles.


If you look at the picture attached you can see that P1 first sends a request so that P3 is waking up. This works.
And now at the same time (marked in red) you can see that P1 on the left and P3 on the right sends a request. P3 to P2 so that P2 wakes up with the message start event and P1 to P2 to the actual event subprocess. Then again it ends in an correlation error for P2 because he is not alive at this point in time.

So for this i first have to solve the first problem before actually working on the second one.
;(

Oh, sorry – I had not understood the message flow in your processes fully.
So: P1 invokes P3 which invokes P2 which then should receive a message from P1, right?

The message flow cannot guarantee that P2 is ready. Either P2 or P3 have to communicate to P1 that P2 has been started. Only then can the message be sent.

When we work in a distributed setting (and I consider multiple communicating processes as a distributed system), messages are the primary (if not the only) means for synchronization. Camunda 7 does not buffer messages, so we have to use message to tell the partner that we are ready or take care of buffering messages.

The latter has been discussed several times in the forum, e.g.:

1 Like

Ok thanks i will have a look on that. :slight_smile:

Hey @StephanHaarmann

i tried to use message buffer plugin you posted but it does not work right away.
Do you have any example or explanation to this plugin too?
I have pasted it into the right folder (resources/plugins/) but there is no visible change within the modeler and also not when deploying and running my processes.
So the messages which come to fast will not be buffered.

Do you have any advice for me?

Hi @SebastianAT,

The message-buffer-plugin is not a plugin for the modeler.
Instead, it extends the Camunda 7 engine.
I do not know any examples that use the plugin. And I don’t know details about its usage.
Maybe @StephenOTT can help us?

1 Like

Seems he is not available. :frowning:

Yes, it seems that way.
So, the documentation contains basic information about process engine plugins:

Maybe this helps?

1 Like

Thanks thats good. I didn’t know this reference.
Hm somehow it looks easy to embed some plugin.

Here is the structure of my camunda spring application:

I guess i should use the Spring beans XML which is mentioned here:
Spring Framework Integration | docs.camunda.org

But idk which one of this topics is the right one to choose:

So, i looked into bootstrapping which is mentioned here:

I found it in src/test/resource/camunda.cfg.xml. I inserted the path where the plugins main class is located (the class which extends ProcessEnginePlugin.

When i deploy and run processes i cannot see any difference. So, i assume that i havn’t configured it well.

For me it’s not clear which expression should be used as a class name in the bean tag in order to access the plugin.

If i run mvn clean then mvn install i see that this bean gets no access. So the class path must be false.

Maybe the pom.xml is not correct, it looks like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.camunda.consulting</groupId>
  <artifactId>P1</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <name>Camunda Spring Boot Application</name>
  <description>Spring Boot Application using [Camunda](http://docs.camunda.org). [The project has been generated by the Maven archetype 'camunda-archetype-spring-boot-7.8.0']</description>

  <properties>
    <camunda.version>7.10.0</camunda.version>
    <!-- 
    7.10.0
    Adjust if you want to use EE:
    <camunda.version>7.8.0-ee</camunda.version>
    Make sure you also switch to the ee webapp dependency below
    -->
    <camundaSpringBoot.version>2.5.4</camundaSpringBoot.version>
    <springBoot.version>2.0.7.RELEASE</springBoot.version>

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <version.java>1.8</version.java>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <failOnMissingWebXml>false</failOnMissingWebXml>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-bom</artifactId>
        <version>${camunda.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>org.camunda.bpm.dmn</groupId>
        <artifactId>camunda-engine-dmn-bom</artifactId>
        <version>${camunda.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${springBoot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
      <!-- 
	    Adjust if you want to use EE:
        <artifactId>camunda-bpm-spring-boot-starter-webapp-ee</artifactId>
    	Make sure you also use an EE version of Camunda - see above
      -->
      <!--  <version>${camundaSpringBoot.version}</version>-->
      <version>3.2.8</version>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
     <!--  <version>${camundaSpringBoot.version}</version>--> 
      <version>3.1.8</version>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>

    <!-- Required to use Spin dataformat support -->
    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-plugin-spin</artifactId>
    </dependency>

    <!-- Used to generate test coverage reports, see https://github.com/camunda/camunda-consulting/tree/master/snippets/camunda-bpm-process-test-coverage -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.camunda.bpm.extension</groupId>
		<artifactId>camunda-bpm-assert</artifactId>
		<version>1.2</version>
		<scope>test</scope>
	</dependency>	
	<dependency>
		<groupId>org.camunda.bpm.extension</groupId>
		<artifactId>camunda-bpm-assert-scenario</artifactId>
		<version>0.2</version>
		<scope>test</scope>
	</dependency> 
    <dependency>
      <groupId>org.camunda.bpm.extension</groupId>
      <artifactId>camunda-bpm-process-test-coverage</artifactId>
      <version>0.3.2</version>
      <scope>test</scope>
    </dependency>

    <!-- java util logging => slf4j -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Add your own dependencies here, if in compile scope, they are added to the jar -->
	<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
	</dependency>
	
	<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
    </dependency>
    
    <dependency>
    	<groupId>org.json</groupId>
    	<artifactId>json</artifactId>
    	<version>20090211</version>
</dependency>

  </dependencies>

  <repositories>
    <repository>
      <id>camunda-bpm-nexus</id>
      <name>Camunda BPM Maven Repository</name>
      <url>https://app.camunda.com/nexus/content/groups/public</url>
    </repository>
    <!-- enable this for EE dependencies
    <repository>
      <id>camunda-bpm-nexus-ee</id>
      <name>camunda-bpm-nexus</name>
      <url>
        https://app.camunda.com/nexus/content/repositories/camunda-bpm-ee
      </url>
    </repository>
    -->
  </repositories>

  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${springBoot.version}</version>
        <configuration>
          <layout>ZIP</layout>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>            
        <configuration>                         
          <mainClass>com.camunda.consulting.P1.CamundaApplication</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>default</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>