WOrker failed to handle job with key sending fail command to broker java.lang.illegalMonitorStateException : current thread is not owner

Hi Team - Need quick and urgent help.

I have requirement where i have list of codes in my process which needs to run against DMN which gives decision and fail type as output. after all codes are executed, there are certain conditions on top of it based on fail type and decision to determine final decision .

How it is implemented:

1)DMN is created for every code and corresponding matching row will return decision and fail type
2) In BPMN - Created Business Rule task with implementation as Jobworker
3) In Jobworker - I have below code to call DMN for all codes :

@JobWorker(type="decisioneval",autocomplete=false)
public void  getdecision(final Activated Job,Final JobClient client)
{
  ZeebeClientBuilder clientbuilder=ZeebeClient.newClientBuilder.gatewayAddress("GATWAY ADDRESS HERE");
  for (int i=0;i<codes.size;i++)
  {
    try(Zeebeclient client=clientbuilder.build())
    {
      inputJson=new JSONObject();
      inputJson.put("riskCode",codes[i[);
      EvaluateDecisionResponse decisioneval=client.newEvaluateDecisionCommand().decisionId("DECISION ID HERE").variables(inputJson.toString()).send().join();

      //get the faill type and decision output from DMN call and store it in seperate  arraylist 
    }
  }
// After above for loop ..additional conditions are added on aggregation ( Arraylist outputs after dmn call for all codes ) and final decision is determined 

at the end i am closing the worker with below
client.newCompleteCommand(job.getkey()).send.join();

Worker is executing fine when i run 2/3 request at time but if i run 40/50 request almost 20/30 request fails in worker with error

Worker failed to handle job with key sending fail command to broker java.lang.illegalMonitorStateException : current thread is not owner

2 questions :

1 . Can you please check if the way DMN is called in for loop is right ?
2. does increasing maxjobsactive,pollInterval will help here in worker method signature ?

Quick help will be appreciated .

@nathan.loding @Niall Can you please help .

Hi @hemantjoshi03 - that particular Java exception means that there’s an issue with how your application is handling threads. From just the code presented it’s impossible to say why that might be, but, as far as I know, that would be a local application issue, not an issue with your model configuration.

Is your DMN just a map between a single risk code and a single result? If so, there are likely better ways than manually executing a DMN decision in a loop like this.