批量捆绑
   由于Ax服务器中批处理线程是可以多个的,而实际批处理作业中线程往往只使用了一个


Class:

/*
批量捆绑
*/
/*class Code*/
public class DemoBatchBundles extends RunBaseBatch
{
str 20 fromSalesOrder, toSalesOrder;
#define.CurrentVersion(1)
#localmacro.CurrentList
fromSalesOrder, toSalesOrder
#endmacro
} public void new()
{
super();
} public container pack()
{
return [#CurrentVersion, #CurrentList]; } private void parmEndBlock( str _toSalesOrder)
{
toSalesOrder = _toSalesOrder;
} private void parmStartBlock(str _fromSalesOrder)
{
fromSalesOrder= _fromSalesOrder;
} void run()
{
SalesTable salesTable;
SalesFormLetter formletter;
Map SalesMap;
; info(fromSalesOrder+':'+toSalesOrder); /* Each task knows the range of work items it needs to process. This range information is already packed when the task is created */
while select * from salesTable
where salesTable.salesId >= fromSalesOrder
&& salesTable.salesId <= toSalesOrder
&& salesTable.documentStatus == DocumentStatus::none
{
formletter = SalesFormLetter::construct(DocumentStatus::Invoice);
formletter.getLast();
formletter.resetParmListCommonCS();
formletter.allowEmptyTable(formletter.initAllowEmptyTable(true));
SalesMap = new Map(Types::Int64,Types::Record);
SalesMap.insert(salesTable.recid,salesTable);
// formletter.parmDataSourceRecordsPacked(SalesMap.pack());
// formletter.createParmUpdateFromParmUpdateRecord(SalesFormletterParmData::initSalesParmUpdateFormletter(DocumentStatus::Invoice, FormLetter.pack()));
formletter.showQueryForm(false);
formletter.initLinesQuery();
formletter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, false, false);
}
} public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
switch(version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
} public static DemoBatchBundles construct(str _fromSalesOrder, str _toSalesOrder)
{
DemoBatchBundles c;
;
c = new DemoBatchBundles();
c.parmStartBlock(_fromSalesOrder);
c.parmEndBlock(_toSalesOrder);
return c;
}

  

Job 测试

/* Here tasks are created to process work items equivalent to the bundle size.
The range between the fromSalesOrder and toSalesOrder is a bundle of work items.
*/ static void scheduleDemoBundlesJob(Args _args)
{
int blockSize=30; //My bundle size
BatchHeader batchHeader;
DemoBatchBundles demoBatchBundles;
SalesTable salesTable;
str fromSalesOrder, toSalesOrder;
str lastSalesId;
BatchInfo batchInfo;
int Counter=0; SalesId _SalesIdFrom,_SalesIdTo;
; _SalesIdFrom = "SSO000001";
_SalesIdTo = "SSO001000"; ttsBegin; select count(RecId) from salesTable
where salesTable.salesId >= _SalesIdFrom &&
salesTable.salesId <= _SalesIdTo &&
salesTable.documentStatus == DocumentStatus::none; info(Strfmt("%1",salesTable.recid )); if (salesTable.recid > 0)
{
batchHeader = BatchHeader::construct();
batchHeader.parmCaption(strFmt('Batch job for DemoBundlesBatch Invoice SalesOrders %1 thru %2', 'SO-00400001', 'SO-00500000')); while select salesid from salesTable
order by salesTable.SalesId
where salesTable.salesId >= _SalesIdFrom &&
salesTable.salesId <= _SalesIdTo &&
salesTable.documentStatus == DocumentStatus::none
{ Counter += 1;
if (Counter ==1)
{
fromSalesOrder = salesTable.salesid;
}
if (Counter == blockSize)
{
toSalesOrder = salesTable.salesid; /* Each task is created to process a bundle of work items (in this case a range of sales Orders)*/ demoBatchBundles = DemoBatchBundles::construct(fromSalesOrder, toSalesOrder);
info(fromSalesOrder+' : ' + toSalesOrder);
batchInfo = DemoBatchBundles.batchInfo();
BatchInfo.parmCaption(fromSalesOrder+' : ' + toSalesOrder);
batchInfo.parmGroupId("COUNTING");
batchHeader.addTask(demoBatchBundles);
Counter = 0;
}
lastSalesId = salesTable.SalesId;
} // This is to handle the spillover
// #SalesOrders in this last bundle will be less than the bundle size if (Counter > 0)
{
toSalesOrder = lastSalesId;
demoBatchBundles = DemoBatchBundles::construct( fromSalesOrder, toSalesOrder);
info(fromSalesOrder+' : ' + toSalesOrder);
batchInfo = DemoBatchBundles.batchInfo();
BatchInfo.parmCaption(fromSalesOrder+' : ' + toSalesOrder);
batchInfo.parmGroupId("COUNTING");
batchHeader.addTask(demoBatchBundles);
} batchHeader.save();
}
ttsCommit;
info('Done');
}
/*
批量捆绑 假设,我们处理10万条记录 #已创建任务 #批处理线程(在我的测试服务器) #可并行执行的并行任务
100 10 10 前10个任务完成后,批处理框架将加载下10个任务并执行,以此类推;
在这种情况下,可能需要加载10次或更多次。
*/

  

AX2009 批处理作业中使用多线程---批量捆绑的更多相关文章

  1. AX2009 批处理作业中使用多线程---顶级采摘

    顶级采摘 是前两种模式的一种混合,使用使用实体表存储单任务模式那样的每个工单,任务每次都取顶行做操作.单任务数不想单任务模式,一个工单一个任务.而是类似批量捆绑那样设置任务数.表:demoTopPic ...

  2. AX2009 批处理作业中使用多线程---独立任务模式

    每个工单独立一个任务. Class /* 独立任务模式 */ class DemoBatchIndividualTasks extends RunBaseBatch { str 20 SalesOrd ...

  3. 多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中【我】

    多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中 package com.xxx.xx.reve.service; import java.util.ArrayL ...

  4. HBase 高性能获取数据(多线程批量式解决办法) + MySQL和HBase性能测试比较

    摘要:   在前篇博客里已经讲述了通过一个自定义 HBase Filter来获取数据的办法,在末尾指出此办法的性能是不能满足应用要求的,很显然对于如此成熟的HBase来说,高性能获取数据应该不是问题. ...

  5. Spring多线程批量发送邮件(ThreadPoolTaskExecutor)

    1,需求:使用多线程批量发送邮件 需要批量发送邮件大概400封左右,但是因为发送邮件受网络限制,所以经常导致等待超时.所以就想到了使用多线程来发邮件,因为是异步的所以返回结果不受发邮件影响. 2,思路 ...

  6. java多线程批量读取文件(七)

    新公司入职一个多月了,至今没有事情可以做,十来个新同事都一样抓狂,所以大家都自己学习一些新东西,我最近在看zookeeper,感觉蛮不错的,和微服务的zuul以及eureka功能类似,只是代码复杂了一 ...

  7. shell脚本(多线程批量创建用户)

    shell脚本中的多线程 很多场景中会用到多线程,例如备份数据库,有100个库,正常备份效率极其低下.有了多线程原本可能需要10个小时备份,现在分10个线程同时去干,只要一个小时就解决了.今天就介绍下 ...

  8. 细说.NET 中的多线程 (一 概念)

    为什么使用多线程 使用户界面能够随时相应用户输入 当某个应用程序在进行大量运算时候,为了保证应用程序能够随时相应客户的输入,这个时候我们往往需要让大量运算和相应用户输入这两个行为在不同的线程中进行. ...

  9. 细说.NET中的多线程 (二 线程池)

    上一章我们了解到,由于线程的创建,销毁都是需要耗费大量资源和时间的,开发者应该非常节约的使用线程资源.最好的办法是使用线程池,线程池能够避免当前进行中大量的线程导致操作系统不停的进行线程切换,当线程数 ...

随机推荐

  1. Maintaining ICM Parameters for Using SSL for As JAVA

    1770585 - How to configure SSL on the AS Java You can use this procedure to configure the necessary ...

  2. CentOS使用nginx部署https服务

    nginx安装参考:https://www.cnblogs.com/taiyonghai/p/6728707.html 自签证书生成参考:https://gmd20.github.io/blog/op ...

  3. zabbix3.0.4 探索主机Discovery自动发现agent主机和zabbix-agent自动注册详细图文教程

    Zabbix 自动发现(Discovery)功能使用 随着监控主机不断增多,有的时候需要添加一批机器,特别是刚用zabbix的运维人员需要将公司的所有服务器添加到zabbix,如果使用传统办法去单个添 ...

  4. Ionic框架搭建简明教程

    1.安装node.js 安装教程:https://www.cnblogs.com/zhouyu2017/p/6485265.html 安装完成后,执行:cnpm install –g cordova ...

  5. pgadmin连接 postgresql远程设置

    背景:通过yum默认方式将pgsql10安装在centos7, pgsql 的配置文件在:/var/lib/pgsql/10/data. 配置文件:postgresql.conf 和 pg_hba.c ...

  6. python大法好——飞机大战完整吧

    # -*- coding:utf-8 -*-import pygamefrom pygame.locals import *import time '''说明1.按下b键,让玩家飞机爆炸 2.爆炸效果 ...

  7. springboot+vue前后端分离,nginx代理配置 tomcat 部署war包详细配置

    1.做一个小系统,使用了springboot+vue 基础框架参考这哥们的,直接拿过来用,链接https://github.com/smallsnail-wh/interest 前期的开发环境搭建就不 ...

  8. java获取当前日期所在的周的周一,并以周一为一周开始

    public String getMonday(String date) { if (date == null || date.equals("")) { System.out.p ...

  9. error: undefined reference to 'android::hardware::details::return_status::~return_status()'

    use hidl , make fail. reason is:missing libs:libbinder

  10. editplus注册码

    EditPlus5.0注册码 注册名 Vovan 注册码 3AG46-JJ48E-CEACC-8E6EW-ECUAW EditPlus3.x注册码 EditPlus注册码生成器链接 http://ww ...