Restarting the ServiceTask when performing a lengthy operation

In the context of the process, it takes a long time to wait for a signal (a response from an external system is expected) from a few minutes to several hours. But with a long wait, Camunda restarts the ServiceTask after about 5 minutes, while the first running thread also remains working. Is it possible to increase the time after which the ServiceTask will be restarted? or to remove the restart of the ServiceTask by timeout?

package com.HospitalBPMN.domain.notations;
import lombok.extern.apachecommons.CommonsLog;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultJobExecutor;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;

@Component
@CommonsLog
public class TestNotation implements JavaDelegate {

    @Override
    public void execute(DelegateExecution delegateExecution) throws Exception {
        log.info( "TestNotation" );
        org.camunda.bpm.engine.impl.jobexecutor.DefaultJobExecutor  defaultJobExecutor = new DefaultJobExecutor();
        defaultJobExecutor.setLockTimeInMillis(1200000);
        try {
            List<String> lst = new ArrayList<>();
            synchronized (lst){
                try {
                    lst.wait(20*60*1000);
                } catch (Exception ex) {
                    log.error(ex.getMessage() + ex);
                }
            }
        }
        catch (Exception ex){
            log.error(ex.getMessage());
            log.error(ex.toString());
        }
        log.info( "TestNotation end" );
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0fcucpd" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.17.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
  <bpmn:process id="Process_Prezentation" isExecutable="true">
    <bpmn:extensionElements />
    <bpmn:startEvent id="StartEvent_1" camunda:asyncAfter="true">
      <bpmn:outgoing>Flow_00a464w</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_00a464w" sourceRef="StartEvent_1" targetRef="Activity_0ucx0ly" />
    <bpmn:serviceTask id="Activity_0ucx0ly" name="test" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:exclusive="false" camunda:class="com.HospitalBPMN.domain.notations.TestNotation">
      <bpmn:extensionElements />
      <bpmn:incoming>Flow_00a464w</bpmn:incoming>
      <bpmn:outgoing>Flow_0qmq03z</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="Event_0zw47t6">
      <bpmn:incoming>Flow_0qmq03z</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0qmq03z" sourceRef="Activity_0ucx0ly" targetRef="Event_0zw47t6" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_Prezentation">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="152" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_1qgdevr" bpmnElement="Activity_0ucx0ly">
        <dc:Bounds x="250" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0zw47t6_di" bpmnElement="Event_0zw47t6">
        <dc:Bounds x="452" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_00a464w_di" bpmnElement="Flow_00a464w">
        <di:waypoint x="188" y="120" />
        <di:waypoint x="250" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0qmq03z_di" bpmnElement="Flow_0qmq03z">
        <di:waypoint x="350" y="120" />
        <di:waypoint x="452" y="120" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

LOG

        Spring-Boot:  (v2.5.4)
        Camunda Platform: (v7.18.0)
        Camunda Platform Spring Boot Starter: (v7.18.0)
...
        2024-04-09 21:17:50,089 INFO  [JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor]] org.camunda.commons.logging.BaseLogger: ENGINE-14018 JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor] starting to acquire jobs
        2024-04-09 21:18:11,854 INFO  [camundaTaskExecutor-2] com.HospitalBPMN.domain.notations.TestNotation: TestNotation
        2024-04-09 21:23:26,865 INFO  [camundaTaskExecutor-3] com.HospitalBPMN.domain.notations.TestNotation: TestNotation
        2024-04-09 21:28:26,867 INFO  [camundaTaskExecutor-1] com.HospitalBPMN.domain.notations.TestNotation: TestNotation
        2024-04-09 21:38:11,854 INFO  [camundaTaskExecutor-2] com.HospitalBPMN.domain.notations.TestNotation: TestNotation end
        2024-04-09 21:38:11,867 WARN  [camundaTaskExecutor-2] org.camunda.commons.logging.BaseLogger: ENGINE-14006 Exception while executing job 8648cc34-f69d-11ee-9ca2-346f2428d27f: OptimisticLockingException. To see the full stacktrace set logging level to DEBUG.
        2024-04-09 21:38:11,870 INFO  [camundaTaskExecutor-2] com.HospitalBPMN.domain.notations.TestNotation: TestNotation
        2024-04-09 21:43:26,866 INFO  [camundaTaskExecutor-3] com.HospitalBPMN.domain.notations.TestNotation: TestNotation end
        2024-04-09 21:43:26,882 INFO  [camundaTaskExecutor-3] com.HospitalBPMN.domain.notations.TestNotation: TestNotation

You set a higher lock timeout, but I think you do it on a wrong job executor instance. Why don’t you do it via the engine configuration?