Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

batch multi threading not working in ax 2012 r3

Posted on by 425

Hi all,

I have followed an example  on a blog  

http://d365technext.blogspot.com/2018/07/batch-multi-threading-d365fo-ax7.html

to replicate the multi threading process and i was successful in replicating the same which is given in the example and it is working fine as given in the blog and the data is getting inserted in the table.

how ever when i tried to  use it in my customization it is not working 

I have created 3 classes

1. main batch class class ELMOInvMultithreadBatch extends RunBaseBatch

i have debugged the code in visual studio during the batch process and found that  debugger does not go into my 2nd class  which is class ELMOINVTask extends RunBaseBatch and run method for the 2nd class is 

public void run()
{
//SLD_DemoBusinessLogic SLDDemoBusinessLogic =new SLD_DemoBusinessLogic();
ELMOInvoiceXML ELMOInvoiceXML = new ELMOInvoiceXML();

try
{
ELMOInvoiceXML.processInit(filename);
info("2");
}
catch
{
info(strFmt("%1",xSession::xppCallStack()));
}
}

and hence my multi threading batch process is not working 

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: batch multi threading not working in ax 2012 r3

    So do you have more than 1 file in that folder and how do you know that it is not creating multiple tasks ?

  • rohit1900 Profile Picture
    rohit1900 425 on at
    RE: batch multi threading not working in ax 2012 r3

    thanks for the reply,

    the below code  is what i am using to add in the multiple batches.

    public void run()

    {

       System.String[] filePaths;

       int             fileCount;

       int             currentFileCount;

       ;

        select firstOnly  FolderFilePathTable

          where FolderFilePathTable.StreamID == 'test';

       filePaths = System.IO.Directory::GetFiles(@FolderFilePathTable.DefaultfilePath, '*.XML',

                                   System.IO.SearchOption::AllDirectories);

       fileCount = filepaths.get_Length();

       try

       {

           for(currentFileCount = 0; currentFileCount < fileCount ; ++currentFileCount)

           {

               filename =   filepaths.GetValue(currentFileCount);

                   if(this.isInBatch())

                   {

                       if(!batchHeader)

                       {

                           batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);

                       }

                       batchHeader.parmCaption("Multiple thread batch jobs for elmo");

                       ELMOInvoiceXMLTask =  new SON_ELMOInvoiceXMLTask();

                       ELMOInvoiceXMLTask.pramFileName(filename);

                       batchHeader.addRuntimeTask(ELMOInvoiceXMLTask, this.parmCurrentBatch().RecId);

                   }

                   else

                   {

                       ELMOInvoiceXML = new ELMOInvoiceXML();

                       ELMOInvoiceXML.processInit(filename);

                   }

           }

           if(!fileCount)

           {

               warning(strFmt('There is no XML file in the folder'));

           }

       }//try

       catch

       {

           info(strFmt("%1",xSession::xppCallStack()));

       }

    }

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: batch multi threading not working in ax 2012 r3

    Could you please share code where you are creating multiple tasks?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans