Exception boundary event not getting triggered


#1

Hi,

need some pointers on an issue that we have where a boundary event attached to a service task not getting fired. Below is the property section of the boundary event.

Here is the delegate class that is attached to a service class with an attached boundary event.

public class ABC implements JavaDelegate,Constants {

  public synchronized void execute(DelegateExecution execution) throws Exception {
			  try{
			….
			….

			Call a Function from class XYZ with some params
			…..
			….

}catch (Exception e) {
LOGGER.info(“exception occured” + e);
throw e;
}
}

}

public class XYZ extends Service implements Constants{

public Integer fun1(String formName,List Map1,Integer Id,String str) throws Exception {

// consume a service to create a request using org.apache.cxf.endpoint.Client  from the stack it looks like there is an exception here which should bubble up and be caught at the top level.

}

}

So when the issue occurs we see that there is a callstack in the logs with “Caused by: java.net.SocketTimeoutException: Read timed out” and the process gets killed. However the behavior we need is that it logs the error and continues to execute with next steps.

Any pointers is much appreciated.


#2

Hi,

You may want to catch the java exception and re-throw it as BpmnError for an error boundary event to take effect.

This [1] pattern thread may be of interest…

regatds

Rob

[1] Pattern - Fail Faster, Best Efforts


#3

HI Rob,

in the code that I shared, there already is a try catch and its being thrown as a java exception. my question was why the boundary wouldn’t pick it and take the exception route?

Thanks
Sandeep


#4

Hi Sandeep,

you must throw a BpmnError. See here [1] for more detail

regards

Rob

[1] https://docs.camunda.org/manual/7.8/user-guide/process-engine/delegation-code/#throw-bpmn-errors-from-delegation-code


#5

Thanks Rob. I will try to write some sample code to test this.

Does this mean, we will have to use BPMNError all the time. Currently the exception handling is set up the way I described above. All seem to work except for the activity where its failing for external service (I see that the boundary event gets triggered for other tasks, but it’s not making any calls to external services).

Thanks
Sandeep


#6

Hi Rob,

I was trying to reproduce this issue and in my repro code the external exceptions are getting trapped by using java.lang.Throwable (not as BPMNError). I will try few different exceptions and let you know. is there any debugging setting that I can enable to get some more information (to enable more logging so we can check what is going on)?

Thanks
Sandeep