Is it possible for a Error boundary event to catch multiple Errors, I have a case like a Java Delegate can throw three different errors and with this Error boundary event I have to capture the errors and based on the errors I have to do different logics.
If an error catch event does not have a specific error code defined it will catch all errors that reach it’s scope.
In a java Delegate I have to catch
throw new BpmnError(“APPLICATION_NOT_AVAILABLE”);
throw new BpmnError(“DB_NOT_AVAILABLE”);
throw new BpmnError(“REQUEST_ERROR”);
so for the above I have 3 catch to catch the above error, but I am not able to catch all those if anyone occurs with one error boundary, please find attached sample tried diagram.bpmn (4.7 KB)
@Niall any info on this please…
@fakrudeen_sarfraz Are you trying to catch all 3 types of errors in single catch event?
As per camunda docs, If errorRef is omitted, the error boundary event will catch any error event, regardless of the errorCode of the error.
In your attached model, I can see that errorRef exists.
Try to remove it “errorRef”.
yes… @aravindhrs
Thanks for your help, I am able to catch all the errors defined. is there a way I can know which error was catched when I reached the Delegate.
I see form docs as “catched a process variable with the name err
will be created that holds the evaluated message.”
I am not able to find such a “err” variable in execution
Try to configure asynchronous continuation before your activity “Test Error Bounday” so you can guarantee that defined process variables get committed to database and accessible.
yes I have configured Async before, but not able to see the err variable as part of error boundary event
@fakrudeen_sarfraz You can refer the below example.
BPMN File: Invoice Process.bpmn (9.0 KB)
Delegates:
@Slf4j
@Component
public class LoggerDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
log.info("Logging for activity {}, invoiceErrorCode:{}, invoiceErrorMessage:{}",
execution.getCurrentActivityName(), execution.getVariable("invoiceErrorCode"),
execution.getVariable("invoiceErrorMessage"));
}
}
@Component("invoiceGenerateDelegate")
public class InvoiceGenerateDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
Long invoiceStatus = (Long) execution.getVariable("invoiceStatus");
if (invoiceStatus.intValue() == 5) {
System.out.println("Invoice processed successfully!!!");
} else if (invoiceStatus.intValue() > 5) {
throw new BpmnError("ORDER_LIMIT_EXCEEDED",MessageFormat.format("Order limit exceeded, current items:{0}", invoiceStatus));
} else {
throw new BpmnError("ORDER_LIMIT_LOWER",MessageFormat.format("Order count is zero, current items:{0}", invoiceStatus));
}
}
}
@Component("invoiceRejectedDelegate")
public class InvoiceRejectedDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
System.out.println(MessageFormat.format(
"Executing InvoiceRejectedDelegate for activity: {0}, Error code:{1}, Error message:{2}",
execution.getCurrentActivityName(), execution.getVariable("errCode"), execution.getVariable("errMessage")));
}
}
Thank you so much, it was very helpful @aravindhrs
Thanks all for your help…
I tried to use the same above BPMN, I get the bellow Error
The transaction was marked for rollback only; cannot commit; nested exception is org.hibernate.TransactionException: Transaction was marked for rollback only; cannot commit
Hi Team,
If I want to throw the event after retries few times. How to do that. Camunda Application in Spring boot.