Job Queue in NAV 2009

havhav Member Posts: 299
Hi all,
I need help in scheduling a job queue in NAV 2009.
I have created a coduenit-Test containing some business logic. The codeunit basically check a field value in one table, does some processing and updates the field value.
I have setup a job queue to execute this codeunit every 1 min.
I have also installed NAV Application Server and have used NASMSnapIn to started the service with below details.
Database Server Name = IM2
Database = NA-Demo Database NAV (6-0)
Company Name = Cronus Canada, Inc.
Start up Parameter = JOBQUEUE
Net Type = TCP/IP Sockets
Object Cache Size = 8000
Service Status = Started

The problem i face is that the codeunit is not getting scheduled for execution.
What am i missing?

Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
«1

Answers

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    i have this same probelmwhen running first time

    i have run codeunit Job Queue Dispacher mannually once then it works perfectly
  • havhav Member Posts: 299
    When i view the eventlog it shows below warning
    "The Application Server for Microsoft Dynamics NAV IM2-SQL could not initialize properly.
    The server will attempt to initialize every 30 seconds until this is successful. "

    Does this mean my NAS is not started properly?

    The link http://msdn.microsoft.com/en-us/library/dd355014.aspx in msdn says that a startup trigger in codeunit 1 with ID 99 is to be created.
    I am not sure what does this means.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • kinekine Member Posts: 12,562
    Yes, it didn't start. See previous error in the log why...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    hav wrote:
    The link http://msdn.microsoft.com/en-us/library/dd355014.aspx in msdn says that a startup trigger in codeunit 1 with ID 99 is to be created.
    The trigger is the 'HASHandler' trigger and should already be part of your codeunit 1. If it didn't have the right trigger, the error message would have said something like 'invalid function'.
  • havhav Member Posts: 299
    Yes i found the trigger NASHandler in codeunit 1.
    I have also found that in order to start NAS i have to run codeunit 448 - Job Queue Dispatcher.
    I had run this codeunit and it seems that the job queue is scheduled.
    However if i open the Job Queue Process list it show one entry as below
    Process is Running : Yes
    Session ID : 56
    User ID : hemant
    Last Job Processed On : 08/27/09 05:36 PM
    Object Type Running : 0
    Object ID Running : 0
    Object Name Running
    From the above i understand that the codeunit Test is still not executed even though the job queue is scheduled.

    Not sure why?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • DenSterDenSter Member Posts: 8,304
    hav wrote:
    I have also found that in order to start NAS i have to run codeunit 448 - Job Queue Dispatcher.
    No you don't have to run that codeunit manually. If you specify the right startup parameter in your NAS MMC snap-in, it will start up automatically, that is the whole point of NAS.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Check the Status of your Job Queue Entry Card. You can Reset the Status so it becomes Ready again.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • havhav Member Posts: 299
    Yes the status has been reset to Ready.
    I tried stopping and starting the service multiple times but the codeunit-Test is not scheduled for execution. Note that the startup parameter is set as "JOBQUEUE".
    Once I run the "Job Queue Dispatcher" manually then only i see the job queue being executed.
    It sounds strange to me.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    hav wrote:
    Yes the status has been reset to Ready.
    I tried stopping and starting the service multiple times but the codeunit-Test is not scheduled for execution. Note that the startup parameter is set as "JOBQUEUE".
    Once I run the "Job Queue Dispatcher" manually then only i see the job queue being executed.
    It sounds strange to me.

    :thumbsup: :thumbsup:
  • havhav Member Posts: 299
    I think i have ran into some problem for which i write below what exactly i have done.
    I first installed NAS on my machine. This created two services IM2-CLASSIC and IM2-SQL, where IM2 is my machine name.
    I then run NASMSnapIn.msc to open NAS MMC. I added one Application Server named "NAS" with following properties
    --> Database Server Name = IM2
    --> Database Name = NA-Demo Database NAV (6-0)-JIT
    --> Company Name = Cronus Canada, Inc.
    --> Start up Parameter = JOBQUEUE
    --> Net Type = Default
    --> Object Cache Size = 8000
    --> Service Status = <blank>
    I now run NAV 2009 Classic Client.
    I created a table Test with two fields:- "No."(Integer) and CurrDateTime(DateTime)
    I then created a codeunit 50000- Test Job Queue
    I set the TableNo property of this codeunit to "Job Queue Entry" and Single Instance = Yes. This added a parameter Rec in the OnRun() trigger of the codeunit. I then wrote below code in this codeunit
    Test.RESET;
    IF Test.FIND('+') THEN
       NextNo := Test."No." + 1
    ELSE
       NextNo := 1;
    
    Test."No." := NextNo;
    Test.CurrDateTime := CURRENTDATETIME;
    Test.INSERT;
    
    The purpose of the codeunit is to insert a record each time the job queue schedules it for execution so as to track how many times the codeunit is called.
    I now setup a new job queue using the Job Queue Entry card and selected the above codeunit. The Earliest Start Date/Time is set as 5 mins after the current date and time. On Recurrence tab all fields are checked and "No. of Attempts to Run" is 0
    I reset the status of the job queue to Ready
    I now started the "NAS" service from the NAS MMC.
    Nothing happened after 5 mins.
    So i manually run the codeunit 448 "Job Queue Dispatcher".
    Now it scheduled the job queue.

    I opened the Test table and saw that one record was created. I waited for some time to see that some record will get inserted but what i noticed is that the Test table didn't contain multiple records.
    I suspected that the codeunit "Test Job Queue" is not getting scheduled for next iteration.
    To ensure this i opened the job queue entry card and what now i noticed is that the Earliest Start Date/Time got changed automatically. I am not sure how this happened.
    I then set the status to on hold, manually correct the Earliest date/time to correspond to current date/time, reset the status back to ready.
    I then opened the Test table. It shows two records.
    I expected more records to be inserted. But no luck.
    I once again went back to Job Queue Entry card and again i saw that the Earliest Start Date/Time has changed to next day.

    From the above i understand that my codeunit is not getting scheduled repeatedly as the Earliest Start Date/Time is changed automatically.

    I am not sure why this happens.

    Can anyone assist me to resolve this issue?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • havhav Member Posts: 299
    Is this behaviour because of "No. of Atempts to Run" set to 0?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    hav wrote:
    Is this behaviour because of "No. of Atempts to Run" set to 0?
    No of attempts is used if the job fails to run, it will try to run it again based on no. of attempts to run if it's not zero.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    Oops! i made a mistake.
    I meant "No. of Minutes between Run" and not "No of Attempts to Run".
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    Yes you need to populate that.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    I tried setting different values in "No of Minutes Between Run" column but it gives "time is not valid" error.
    Setting value to 0 removes the error.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    Did you populate the start and end datetime?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    No i left them as empty
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    please populate Earliest Start Date/Time
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    The Earliest Start Date/Time was already populated.
    But after setting the Start Time and End time the error is not displayed.

    I have another query w.r.t. display of messages when job queue is executing.
    I wrote a simple message in a codeunit and schedule it for execution every 2 min interval and what i found is that after every 2min the message is displayed.
    If i am not mistaken then NAS does not allow messages.
    I am not sure why messages are displayed.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    The messages are displayed in eventlog.
    change it to error('my error");

    so that you'll see it in NAV log
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    Hey, untill now i was running Classic Client and could see that the job queue was getting executed.
    When i switched to Role Tailored Client i could not see the job queue getting executed.
    What additional thing i have to do in RTC so as to allow the job queue to execute.
    Note that when i first start the Classic Client i have to run Job Queue Dispatcher atleast once in order to schedule the job queue. This is a strange behaviour i am noticing so far.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    You need to install NAS (Navision Application Server) with startup parameter JOBQUEUE.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    ara3n wrote:
    You need to install NAS (Navision Application Server) with startup parameter JOBQUEUE.
    Please re-read the first message in this thread ;-)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ara3nara3n Member Posts: 9,256
    The Original Poster apparently doesn't get it.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    Yes i do have NAS installed on my machine with Startup Parameter as JOBQUEUE.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    Then the question of on what to do on RTC doesn't make sense. NAS is doing all the work.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    Yes i do agree but then the problem is why i am unable to see the expected behaviour on RTC?
    I tried creating a sample table with two fields and wrote a codeunit which inserts some data in this table. I setup job queue for this codeunit.
    When i run Classic Client and open the sample table i can see records being inserted at scheduled time but when i run Role Tailored Client and open the same table in SQL Server i do not see any new records being inserted.

    Is it something that i am missing?
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    Yes, you need to Refresh the screen. F5.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • havhav Member Posts: 299
    Yes i had checked it by refreshing the screen also.
    I am not able to troubleshoot this problem anymore.
    I wonder if anyone has tried running jobqueue from RTC.

    What i suggest for you to try and work out what i did, at your end and let me know if you are able to run job queue from RTC.

    (1) Create a table say Test with two fields say "No." (Integer) and CurrDateTime(DateTime)

    (2) Create a codeunit say Test Job Queue. Set TableNo property of this codeunit to Job Queue Entry so that OnRun() has a parameter Rec referring to this job queue entry record.

    (3) Write below code in the OnRun() trigger of this codeunit:-
    Test.RESET;
    IF Test.FIND('+') THEN
       NextNo := Test."No." + 1
    ELSE
       NextNo := 1;
    Test."No." := NextNo;
    Test.CurrDateTime := CURRENTDATETIME;
    Test.INSERT;
    

    (4) Setup a job queue for this codeunit with Earliest Start Date/Time as today, set it as recurring Job for all working days, set Start Time = 9:30 AM , End Time = 6:00 PM and No. of Minutes Between Run = 1.

    (5) Assuming that NAS service is started and running, open table Test in Classic Client at an interval of 1min.
    The table Test will be empty.
    Now run codeunit "Job Queue Dispatcher". You will see that the cursor will change to busy cursor at every 1min.
    Once again open table Test. You will see record getting inserted at every 1 min.

    (6) Close Classic Client. Open table Test in SQL Server.

    (7) Run RTC and wait for few mins. Go back to SQL Server and refresh table Test.
    You will see that after the time Classic Client was closed no new records are getting inserted in table Test although RTC is running.

    Can you please do this simple exercise and let me know the outcome?

    Awaiting for your reply
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • ara3nara3n Member Posts: 9,256
    hav wrote:
    (5) Assuming that NAS service is started and running, open table Test in Classic Client at an interval of 1min.
    The table Test will be empty.
    Now run codeunit "Job Queue Dispatcher". You will see that the cursor will change to busy cursor at every 1min.
    Once again open table Test. You will see record getting inserted at every 1 min.

    Please check and make sure NAS is started and running. CHeck the eventlog, you should see a message that says.
    NAS has started with paramater JOBQUEUE.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.