How can we skip failed correlation and progress the process

I have created a process and trying to correlate another process and it works fine if the correlation get success.

If it is unable to find the process to correlate then it is going into failure state, please let me know how can we skip this failure and progress the process further (even there is no correlating process).

I am doing this with send task and used delegate java class for correlation.

Hi,
you can simply catch the exception and ignore it.
The task only fails if the exception is not handled.

HI Stephan,
Thank you for the update, I have used the try catch in java class but it is giving below exception (if the correlating process is not available, no issue if it is available) and the process instance is going into failure state:

org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:870)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:707)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:152)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)

below is my process:

image

below is my code:

 Map<String, Object> map = new HashMap<String, Object>();
  String payload = (String) execution.getVariable("Payload");
     map.put("continueEventMsg", payload);
    Map<String, Object> correlate = new HashMap<>();
    String correlateName = (String) execution.getVariable("CorrelateName");
    String correlateValue = (String) execution.getVariable("CorrelateValue");
    correlate.put(correlateName,correlateValue);
    try {
        runtimeService.correlateMessage("continueEventMsg", correlate, map);
    }
    catch (Exception ignored) {
       LOGGER.info("Unable Correlate process");
    }
    LOGGER.info( "PFO completed");
}

Hi @venky1982,

Please excuse my delayed response — I was traveling and had limited access to the forum.

First, let me explain that this behavior is intended. According to the BPMN standards, messages are used for 1-to-1 communication. A message that is sent mus always be received. Since Camunda 7 does not implement message buffering, an exception is raised if no recipient is found and the exception causes an incident.
While I thought a simple try-catch would avoid the incident, I was clearly wrong.

However, Camunda 7 offers another non-BPMN conform method for correlating messages. If you use correlateAllWithResult you change the behavior to a 1-to-m correlation, where m can be any number. (the java-doc does not list the mismatching correlation exception; thus, I assume that that’s the behavior: MessageCorrelationBuilder (Camunda Platform Javadocs 7.18.0-ee))

    Map<String, Object> map = new HashMap<String, Object>();
    String payload = (String) execution.getVariable("Payload");
    map.put("continueEventMsg", payload);
    Map<String, Object> correlate = new HashMap<>();
    String correlateName = (String) execution.getVariable("CorrelateName");
    String correlateValue = (String) execution.getVariable("CorrelateValue");
    List<MessageCorrelationResult> results = runtimeService.createMessageCorrelation("continueEventMsg")
            .processInstanceVariableEquals(correlateName, correlateValue).
            .setVariables(map)
            .correlateAllWithResult();
    if (results.isEmpty()) {
        LOGGER.info("Unable Correlate process");
    }
    LOGGER.info( "PFO completed");
}

Can you give this a try and report back, whether it worked?
Be aware that this message may correlate to multiple matching instances.

Thank you Stephan, it worked.