Pages

Wednesday, July 16, 2014

Force the batch server to execute batch jobs immediately and bypass the 60 second wait in one line of code! - [AX 2012]

In AX 2012, if you want to force the batch server to immediately check for awaiting batch jobs and execute them without waiting the 60 seconds for the server to discover them, you can call:

xApplication::checkForNewBatchJobs();

Why might you need this?

In my case, I need to call this because I think there is a bug caused by a race condition that can occur with reliable asynchronous (SysOperationExecutionMode::ReliableAsynchronous) processes that are called from the client.

What happens when you call a reliable asynchronous process client side, two things happen at the same time from `\Classes\SysOperationController\doBatch`:

  • Batch task record is inserted to \Data Dictionary\Tables\Batch)
  • Some sort of new thread is spun up asynchronously via `\Classes\SysOperationController\asyncWaitForBatchCompletion`

So, my theory on what can happen is the async polling process (`\Classes\SysOperationFrameworkService\waitForBatchJob`) will try and select the Batch record and may not find it because the Batch record hasn't finished inserting.

In my case, I've overloaded the doBatch() method and put some tracking logic with pessimisticLock that slows down the Batch insert just enough to periodically cause this...so I end up with batch jobs sometimes that are waiting ~60 seconds to be picked up.

10 comments:

  1. Good post Alex.
    I had trouble on a demo contoso box where the batch jobs didn't start. (I think data got screwed up in the background)
    Running the one line in a job saved me time.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. youtube abone satın al
    cami avizesi
    cami avizeleri
    avize cami
    no deposit bonus forex 2021
    takipçi satın al
    takipçi satın al
    takipçi satın al
    takipcialdim.com/tiktok-takipci-satin-al/
    instagram beğeni satın al
    instagram beğeni satın al
    btcturk
    tiktok izlenme satın al
    sms onay
    youtube izlenme satın al
    no deposit bonus forex 2021
    tiktok jeton hilesi
    tiktok beğeni satın al
    binance
    takipçi satın al
    uc satın al
    sms onay
    sms onay
    tiktok takipçi satın al
    tiktok beğeni satın al
    twitter takipçi satın al
    trend topic satın al
    youtube abone satın al
    instagram beğeni satın al
    tiktok beğeni satın al
    twitter takipçi satın al
    trend topic satın al
    youtube abone satın al
    takipcialdim.com/instagram-begeni-satin-al/
    perde modelleri
    instagram takipçi satın al
    instagram takipçi satın al
    takipçi satın al
    instagram takipçi satın al

    ReplyDelete
  4. You can make a video about your batch server and how to use it. I would publish such video on youtube and get many likes from here https://soclikes.com

    ReplyDelete