web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Parallel batch tasks

(0) ShareShare
ReportReport
Posted on by 3,542

Hi folks

I have a resource intensive job which may benefit from parallel processing. This is the first time I am using this functionality.

Firstly - I am unsure whether my wording is correct. I am referring to BatchHeader.addRuntimeTask(someChildTask). I assume that the functionality enables one to run processes simultaneously.

I have studied a few examples in the standard application. Most of them are used in RunBaseBatch. Nevertheless I can use the logic with SysOperation. But they all differ very much. And many of them include recalling the host controller for each sub process (with different parameters). This does not make sense to me - it should still be the same controller, but different operations. Clarification please 

My current implementation looks something like this:

final internal class XYZController extends SysOperationServiceController
{
    static void main(Args _args)
    {
        XYZController controller = new XYZController();
        controller.initializeFromArgs(_args); //class, method and execution mode specified on the menu item
        controller.startOperation();
    }
    
    protected boolean canRunInNewSession()
    {
        //super() //do not call super
        return true;
    }
    
    boolean mustGoBatch()
    {
        //super //do not call super
        return true;
    }
    
    void run()
    {
        //this is where most of the examples do the "splliting".
        //I do not understand this - isn't there a more logical way to do this?
        //I mean we do not want to duplicate the process - which we are effectively doing here.
        //We want to split the process. And then we won't be creating new controllers.
        //We will be creating new Operation classes.
        //nevertheless, here is the current implementation
    
        XYZContract contract = this.getDataContractObject();
        if (!contract.parmTaskPortion())
        {
            //if a task portion has not been assigned - then we are in the header
            ttsbegin;
            BatchHeader batchHeader = this.batchInfo().parmBatchHeader();
            
            //I see a lot of examples where a runtime task is created for the original process as well
            //Is that really necessary?
            //XYZController controller = new XYZController();
            //controller.initializeFromArgs(this.parmArgs());
            //batchHeader.addRuntimeTask(controller,batchHeader.parmBatchHeaderId());
            
            Array portionArray = returnAnArrayThatSplitsTheTaskIntoPortions;
            for (int i = 1; i <= portionArray.lastIndex(); i  )
            {
                XYZController controller = new XYZController();
                controller.initializeFromArgs(this.parmArgs());
                controller.parmShowDialog(false);
                
                //I also see a lot of examples that do this:
                //controller.unPack(this.pack());
                //what does it do? Is it necessary?
                
                XYZContract portionContract = controller.getDataContractObject();
                portionContract.parmTaskPortion(portionArray.value(i);
                
                batchHeader.addRuntimeTask(controller,batchHeader.parmBatchHeaderId());
                //the tasks aren't dependant - no need to call batchHeader.addDependancy() ?
            }
            batchHeader.save();
            ttscommit;
        }
        
        super();
        
    }
}

final class XYZOperation extends SysOperationServiceBase
{

    final void operation(XYZContract _contract)
    {
        XYZTaskPortion taskPortion = _contract.parmTaskPortion();
        if (taskPortion)
        {
            //if we are not in the header and actually in one of the sub processes that handle a portion of the whole
            this.doSomethingWithThatPortionOfTheTask(taskPortion);
        }
    }
    
    private void doSomethingWithThatPortionOfTheTask(XYZTaskPortion _taskPortion)
    {
        //massive logic
    }
}

My question is: how should parallel processing be accomplished? Should it be placed in run() in the controller? If it should, please explain.

And then as a side question - is it possible to accomplish parallel processing for non-batch processes? Because currently I need to ensure that the process goes batch, or I'll need to check whether we are in batch. I mean it will be quite nifty if an asynchronous non-batch job could also benefit from parallel processing.

Thanks for your attention.

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi,

    As we dicussed we will move to thread community.dynamics.com/.../994138

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans