Job Queue stops when lock time out occurs

Running NAS with Job Queue will start a timer to process Job Queue Entries every two seconds. In the original code the Timer is disabled before checking the Job Queue Entries and then enabled again after the process. If NAS will not be able to read the Job Queue Entry then the function will exit without enabling the Timer and nothing will be processed.

The original code in Codeunit 448 is
[code htmlscript=”false”]HandleRequest()
JobQueueSetup.GET;
IF NOT JobQueueSetup."Job Queue Active" THEN
EXIT;

NavTimer.Enabled := FALSE;

ThisSessionIsActive := UpdateJobQueueSession(JobQueueEntry,FALSE);

CleanUpJobQueue;
COMMIT;

NavTimer.Enabled := TRUE;[/code]
I suggest that you will find a suitable period of time where everything in the Queue should be processed and change the behaviour. Do not disable the timer, just change the interval.  Here I change the interval to five minutes.

The replacement code would then be
[code htmlscript=”false”]HandleRequest()
JobQueueSetup.GET;
IF NOT JobQueueSetup."Job Queue Active" THEN
EXIT;

NavTimer.Enabled := FALSE;
NavTimer.Interval := 5 * 60 * 1000; // 5 min
NavTimer.Enabled := TRUE;

ThisSessionIsActive := UpdateJobQueueSession(JobQueueEntry,FALSE);

CleanUpJobQueue;
COMMIT;

NavTimer.Enabled := FALSE;
NavTimer.Interval := 2 * 1000; // 2 sec.
NavTimer.Enabled := TRUE;[/code] 

5 Replies to “Job Queue stops when lock time out occurs”

  1. I didn’t get your target.
    “If NAS will not be able to read the Job Queue Entry then the function will exit without enabling the Timer and nothing will be processed.”
    I thought that Navision will try again with the code at last line (after 2 sec):

    COMMIT;
    CleanUpJobQueue;
    COMMIT;

    NavTimer.Enabled := TRUE;

  2. This looks very useful but unfortunately the code for Nav 2016 is significantly different but the system suffers from the same issues. Trying to find a solution but not having any joy – any ideas, please?

    1. Hi Craig
      The reason for the TryFunction is to catch a deadlock that has been crashing the job queue. Put that part into a dedicated Codeunit and use the Success := CODEUNIT.RUN to trap the error.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.