# How to stop the Process Instance when the job reach LOCK\_EXP\_TIME

**URL:** <https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130>\
**Category:** Discussion & Questions\
**Created:** [October 12, 2023, 11:36am UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130 "2023-10-12T11:36:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacehouse](https://forum.camunda.io/user_avatar/forum.camunda.io/spacehouse/32/27114_2.png) [@spacehouse](https://forum.camunda.io/u/spacehouse)\
**Post date:** [October 12, 2023, 11:36am UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/1 "2023-10-12T11:36:59Z")

</div>

hi，  
I am using camunda7.17.0.  
During the execution process, I found that when the task was executed to LOCK\_EXP\_TIME is reached, a retry will be triggered. So I tried to set the retry count to 0 when starting the process, and then the process reached LOCK\_EXP\_TIME, there is no retry, but the process cannot continue.  
I wonder if I can monitor this LOCK\_ EXP\_ TIME, then stop the process after arrival LOCK\_ EXP\_ TIME. Or can I rewrite the retry strategy? Stop the process without retry.

---

<div class="post-metadata">

**Author:** ![rohwerj](https://forum.camunda.io/user_avatar/forum.camunda.io/rohwerj/32/33352_2.png) [@rohwerj](https://forum.camunda.io/u/rohwerj)\
**Post date:** [October 13, 2023, 11:58am UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/2 "2023-10-13T11:58:38Z")

</div>

Maybe I don’t understand your question correctly, so let me try to elaborate on what I think you’re asking about.  
The lock expiration time of a job has nothing in so far to do with the retry count. If a job is fetched by a worker, it’s locked by this worker by setting values into the columns LOCK\_EXP\_TIME\_ and LOCK\_OWNER\_ in the table ACT\_RU\_JOB.  
Once the lock expiration time is reached, the job can be locked again by another worker, as the other worker somehow failed to complete the job (maybe due to a crash).  
The retry count on the other hand is decreased, once a job worker has an exception while trying to execute a job. When the retry count reaches zero, the job won’t be retried again without manual intervention.

---

<div class="post-metadata">

**Author:** ![GotnOGuts](https://forum.camunda.io/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@GotnOGuts](https://forum.camunda.io/u/GotnOGuts)\
**Post date:** [October 13, 2023, 5:32pm UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/3 "2023-10-13T17:32:09Z")

</div>

Conceptually (but not 100% accurate):

 ![JobLock](https://forum.camunda.io/uploads/default/original/3X/9/a/9ac6db7978cad5747a7e98ab5dd0860306720693.png)

@spacehouse If you set the retries to 0, as long as the job is not failed, it should simply return to the queue, and another (or the same) worker can pick it back up again to try the job. If your external worker sends a FailJob back because the service that it’s working with didn’t reply in time, and the retries is 0, then an incident will be raised and manual intervention would be required to start the process back up again.

---

<div class="post-metadata">

**Author:** ![rohwerj](https://forum.camunda.io/user_avatar/forum.camunda.io/rohwerj/32/33352_2.png) [@rohwerj](https://forum.camunda.io/u/rohwerj)\
**Post date:** [October 13, 2023, 5:51pm UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/4 "2023-10-13T17:51:49Z")

</div>

That is what I meant. Those are two different things. Locks are all about whether a job is available for execution by a worker (or currently locked by some worker).  
On the other hand the retry count is used to determine whether a failed job should be retried or will raise an incident (when retry count is zero).

---

<div class="post-metadata">

**Author:** ![spacehouse](https://forum.camunda.io/user_avatar/forum.camunda.io/spacehouse/32/27114_2.png) [@spacehouse](https://forum.camunda.io/u/spacehouse)\
**Post date:** [October 16, 2023, 9:15am UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/5 "2023-10-16T09:15:02Z")

</div>

@rohwerj @GotnOGuts Thank you very much for your reply. I did make a mistake. It is not the retry that causes the job to repeat. It is the periodic scheduling of ‘AcquireJobsCmd’. After the job reached the LOCK\_EXP\_TIME\_, it becomes acquirable. Then it can be picked up by the AcquireJobsCmd scheduling and executed in another thread. Even though the job has not yet completed.  
Now, I want to know what I can do when a job reaches its LOCK\_EXP\_TIME\_?

---

<div class="post-metadata">

**Author:** ![rohwerj](https://forum.camunda.io/user_avatar/forum.camunda.io/rohwerj/32/33352_2.png) [@rohwerj](https://forum.camunda.io/u/rohwerj)\
**Post date:** [October 16, 2023, 9:54am UTC](https://forum.camunda.io/t/how-to-stop-the-process-instance-when-the-job-reach-lock-exp-time/48130/6 "2023-10-16T09:54:34Z")

</div>

@spacehouse Are we talking about an external task? In that case you worker could extend the lock, when it needs more time to execute the task.

> **[External Tasks | docs.camunda.org](https://docs.camunda.org/manual/7.19/user-guide/process-engine/external-tasks/#extending-of-locks-on-external-tasks)**
>
> documentation of the Camunda Platform 7

If it’s not an external task, you could either change the property lock-time-in-millis in the configuration of the job executor or switch to an external task to have a more fine grained possibility to extend the lock (as shown above).  
Here the link to the configuration of the job executor for a spring boot application:

> **[Process Engine Configuration | docs.camunda.org](https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/configuration/#camunda-engine-properties)**
>
> documentation of the Camunda Platform 7
