Job Queue Entry keeps status <<In Process>>

sirkniosirknio Member Posts: 7
Hi All,

When I schedule a job queue Entry, usually I set its status in Ready. The process executes the job according to the schedule, and when the NAS service executes the process, it uses the codeunit 448 to execute my process which I created.

Usually, the first step is set the Job Queue Entry status <<In Process>> and when any error appears with my codeunit, my process is stopped, and CU 448 insert a record in Job Queue Entry Log to inform the error, and the Job Queue Entry is set newly like "Ready" for next scheduling.

However, in some cases the record in Job Queue Entry Log is inserted but Job Queue Entry keeps status "In Process", and when the NAS Service try to execute again the process, the CU 448 filters only the Job Queue with status Ready, and my codeunit will not be to execute again.

Someone know why?

Comments

  • since2002since2002 Member Posts: 25
    I don't know the WHY except it happens to us generally the early stages of implementing a new piece of functionality when we get a hard error that we didn't expect or code for. Resetting the Job Status fixes the issue assuming the data is corrected or the condition that causes the error can be handled in code
  • geordiegeordie Member Posts: 655
    Maybe the process contain a confirm or some functions which require user interface?
    In that case your job stay in process waiting for an input.
  • sirkniosirknio Member Posts: 7
    geordie wrote:
    Maybe the process contain a confirm or some functions which require user interface?
    In that case your job stay in process waiting for an input.

    No geordie, I don't include any message or window to user interface. When I execute the process manually any functions which require user interface is shown.
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    sirknio wrote:
    geordie wrote:
    Maybe the process contain a confirm or some functions which require user interface?
    In that case your job stay in process waiting for an input.

    No geordie, I don't include any message or window to user interface. When I execute the process manually any functions which require user interface is shown.
    It also wouldn't create the Job Queue Log Entry if it would wait for some action or remains in some endless loop or something like that. This happens for example when you try to execute an external component and NAV waits for some feedback of it but it never gets that feedback.

    Also, when you run Job Queue on NAS it won't let you if there's any user interaction needed.

    I know this behaviour only from scenarios since2002 describes. There must be any hard error that leads to a situation that doesn't allow Job Queue to finish properly. Assuming you run it on NAS, please have a look at the Windows Event Log to see if there's any error message in it.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • sirkniosirknio Member Posts: 7
    I found the solution in this link from Microsoft, the problem is on standard code. You need to replace this existing code C448:

    ...
    WasSuccess := CODEUNIT.RUN(CODEUNIT::"Job Queue Start Codeunit",JobQueueEntry);
    IF WasSuccess THEN BEGIN
    IF JobQueueEntry."Recurring Job" THEN BEGIN
    JobQueueEntry."No. of Attempts to Run" := 0;
    JobQueueEntry.Status := JobQueueEntry.Status::Ready;
    IF NOT JobQueueEntry.MODIFY THEN
    JobQueueEntry.INSERT;
    END;
    END ELSE BEGIN
    IF JobQueueEntry."Maximum No. of Attempts to Run" > JobQueueEntry."No. of Attempts to Run" THEN BEGIN
    JobQueueEntry."No. of Attempts to Run" := JobQueueEntry."No. of Attempts to Run" + 1;
    JobQueueEntry.Status := JobQueueEntry.Status::Ready;
    IF NOT JobQueueEntry.INSERT THEN
    JobQueueEntry.MODIFY;
    END;
    END;
    ...
    

    for this one:
    ...
    WasSuccess := CODEUNIT.RUN(CODEUNIT::"Job Queue Start Codeunit",JobQueueEntry);
    IF WasSuccess THEN BEGIN
    IF JobQueueEntry."Recurring Job" THEN BEGIN
    JobQueueEntry."No. of Attempts to Run" := 0;
    JobQueueEntry.Status := JobQueueEntry.Status::Ready;
    IF NOT JobQueueEntry.MODIFY THEN
    JobQueueEntry.INSERT;
    END;
    END ELSE BEGIN
    IF JobQueueEntry."Maximum No. of Attempts to Run" > JobQueueEntry."No. of Attempts to Run" THEN BEGIN
    JobQueueEntry."No. of Attempts to Run" := JobQueueEntry."No. of Attempts to Run" + 1;
    JobQueueEntry.Status := JobQueueEntry.Status::Ready
    
    // Add the following lines.
    END ELSE 
    JobQueueEntry.Status := JobQueueEntry.Status::Error; 
    // End of the added lines.
    
    IF NOT JobQueueEntry.INSERT THEN
    JobQueueEntry.MODIFY;
    END;
    ...
    

    Remember this is only for Dynamics NAV 2009 and 2009 SP1

Sign In or Register to comment.