AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 31.07.2018, 23:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
d365technext: Batch Multi threading D365FO AX7
Источник: http://d365technext.blogspot.com/201...365fo-ax7.html
==============


Batch Multi threading D365FO AX7



Normally, when we schedule our RunBaseBatch class as a batch job, it will create single task. Which will responsible to execute complete process in single thread.


But, As you know like AX-2009 and AX-2012. In D365FO We can add multiple AOS server in single batch group and they can process the multiple task simultaneously.


In this demo I will show, How to create multi threading Batch job.

following are the steps

Step-1 Create a table for demo purpose in our demo we keep table name is SLD_DemoTable.




Step-2 create a class with name SLD_DemoBusinessLogic and write your business logic in this class.

In demo I write only insert records in table and show you guys how it works.






Reference Code
class SLD_DemoBusinessLogic
{


public void processInit(VendTable _vend)
{
SLD_DemoTable SLDDemoTable;


SLDDemoTable.clear();
SLDDemoTable.VendName=_vend.name();
SLDDemoTable.VendAccount=_vend.AccountNum;
SLDDemoTable.insert();


}



}

Step-3 create a batch job class with name SLD_DemoMultiThreadTask.
This class we will use as Task in main batch job.





Step-4 In this class We Create a getter setter to store vend table buffer;
Step-5 Create object of our business logic class and execute method



Reference Code
public class SLD_DemoMultiThreadTask extends RunBaseBatch
{

VendTable ventTableBuffer;
#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
ventTableBuffer
#ENDMACRO


public ClassDescription caption()

{
ClassDescription ret;

ret = 'Update Multiple Thread task';

return ret;

}


container pack()
{
return [#CurrentVersion,#CurrentList];
}


public boolean unpack(container _packedClass)
{
int version = conPeek(_packedClass,1);

switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = _packedClass;
break;
default:
return false;
}
return true;
}


public void pramVendBuffer(VendTable _vend)
{
ventTableBuffer=_vend;
}


public void run()
{
try
{
SLD_DemoBusinessLogic SLDDemoBusinessLogic=new SLD_DemoBusinessLogic();


SLDDemoBusinessLogic.processInit(ventTableBuffer);

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



}

Step-6 Now Create main batch job which will responsible to create multiple task in single batch job.






Reference Code
class SLD_DemoMultiThreadBatch extends RunBaseBatch
{
BatchHeader batchHeader;


VendTable vendTable;



public static void main(Args args)
{
SLD_DemoMultiThreadBatch objMultiThread = new SLD_DemoMultiThreadBatch();


if (objMultiThread.prompt())
{
objMultiThread.run();
}
}


void run()
{
SLD_DemoMultiThreadTask SLDDemoMultiThreadTask;



try
{

while select firstonly10 vendTable
{
if(this.isInBatch())
{
if(!batchHeader)
{
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
}
batchHeader.parmCaption("Multiple thread batch jobs");
SLDDemoMultiThreadTask = new SLD_DemoMultiThreadTask();
SLDDemoMultiThreadTask.pramVendBuffer(vendTable.data());
// add tasks to the batch header
batchHeader.addRuntimeTask(SLDDemoMultiThreadTask, this.parmCurrentBatch().RecId);
}


else
{


// execute your code here when not running in batch
}
}
if(batchHeader)
{
// save the batchheader with added tasks
batchHeader.save();
}


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


public container pack()


{


return conNull();


}


public boolean unpack(container packedClass)


{


return true;


}



}


Step-7 Now create an Action menu item and reference our batch job SLD_DemoMultiThreadBatch .




Step-8 Build and sync database and module and run the job.
Step-9 Navigate to you batch job page and find your job and check Job Task.






Step-10 before execution of the batch job check the demo table.
you can check the below screen shot currently table is empty.


After execution of the job table filled with vendors names.



Please feel free to contact me if you are facing any issue during implementation of this blog





Источник: http://d365technext.blogspot.com/201...365fo-ax7.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: How to Enable Multi-Factor Authentication for the New Dynamics AX (Dynamics AX7) Blog bot DAX Blogs 0 22.09.2016 00:11
patrickmouwen: AX7 – My top 12 highlights Blog bot DAX Blogs 0 27.02.2016 13:11
Axilicious:Business Operation Framework and multi-threading Blog bot DAX Blogs 0 25.02.2012 05:42
axinthefield: Optimizing AX Batch Performance - Batch Group Configuration Blog bot DAX Blogs 0 01.04.2011 13:11
axaptapedia: Batch processing Blog bot DAX Blogs 0 29.01.2009 17:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 16:01.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.