Options

Running Job Queue through NAV Web service for Unlimited Comp

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,496
edited 2009-01-30 in Download section
Running Job Queue through NAV Web service for Unlimited Companies
I had posted on mibuso a while back on how to use two NAS instances to run job queue for unlimited amount of companies. Here is the link: viewtopic.php?f=7&t=22633. You had to purchase an additional NAS user license in order to use it. Dynamics NAV 2009 comes with web service, and you can publish any Code unit or Page by default. You will need to purchase one user but for webservice, but it much cheaper. In this blog, I will show you how to setup JOB QUEUE to schedule to run jobs across companies. The advantages of using Web Services is that you can run multiple jobs at the same time for multiple companies. What I've experienced with NAV 2009 Web Service is that once you call a web service function, you can disconnect and Service Tier will finish the job and commit the transaction.

In addition you don't have to modify any processing/posting jobs that have dialog windows displayed. The Service tier simply ignores them. For example you can run adjust cost report without modifying any objects from Job queue. In addition, the solution I've created does not modify any existing objects!!!

This fob file is uploaded as support for the thread Job Queue through NAV Webservice for mulitple Companies.
Object is Codeunit 50000.

http://www.mibuso.com/dlinfo.asp?FileID=1039

Discuss this download here.

Comments

  • Options
    ara3nara3n Member Posts: 9,256
    Here is the blog with more info

    http://mibuso.com/blogs/ara3n/2009/01/28/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    diogomadiogoma Member Posts: 3
    Hi Ahmed,
    I am impressed with your work and efforts to help everyone! ;)
    I have a NAV 2017 installation and I would like to use your functionality of Job Queue for multiple companies. I suppose it's possible right?
    I think the link that defines the required steps is broken, can be? Please point to the right link, or if I am looking in the wrong place.

    Going to my issue, is basically that I have already the Job Queue defined with the correct codeunit to be processed in all companies, but it requires to my user to log in to each every company to automatically run the Job Queue, not doable. I have 120 companies! to run :-)!

    Many thanks for your guidance!
    Kind regards
    DMA
  • Options
    krikikriki Member, Moderator Posts: 9,098
    Give this one a look: https://mibuso.com/howtos/how-to-use-powershell-to-test-your-nav-webservice.

    I killed the NAS completely and use SQL Server Agent that runs PowerShell that calls a NAV webservice. Works as a charm!
    Negative is that you need to set up jobs in SQL Server Agent. Creating new one-off jobs in Jobqueue doesn't work. But I am quite sure it is possible to implement that too. Never needed it, so I didn't look into it yet.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    Remco_ReinkingRemco_Reinking Member Posts: 74
    You can build a webservice function that will be called from a job queue entry.
    This function will execute in the company you need.
    Problem with batch jobs is that they can take a long time to complete.
    So your webservice call will return with an timeout error.

    Possible solution:

    Using a few webservice functions, all within the company needed. The url contains the companyname where you want it to run, so loop through your companies and do the following sequence for each company.
    • create a non recurring job queue entry record with all needed parameter (like which codeunit to run) and return the Job Queue Entry ID to the consuming function. This will be used to start and monitor it
    • Start to execute this Job Queue Entry using IF CODEUNIT.RUN(CODEUNIT::"Job Queue Start Codeunit",JobQueueEntry), discard the time-out, but return any error and handle it properly.
    • in a loop monitor if the job queue entry still exists and still running: do this by checking the job queue log entries, as long as the field "End Date/Time" = 0DT it is still running. If no log entry is created, the job probably did not start properly.

    So it is actually same idea as kriki is using, but then from within NAV using one job queue NAS
Sign In or Register to comment.