I am trying to multi-thread a batch process. Based on processing, I have populated a temporary table with a list of recIDs. Based on the number of recIDs and number of processing threads specified, I then break this list up, create batch tasks, and send each task a piece of the list to process.
The tasks are being created as I would expect, but they don’t have the list of records to process. I’m also sending a NoYesCombo that I have confirmed is being sent correclty. I have tried sending the records in an object of my temporary table and in a list. I suspect both have the same problem of being cleared out and not saved for processing.
Here is the run method for the class that does the creation of the batch tasks:
void run()
{
BatchHeader batchHeader;
CustomConfirmTask workOrderConfirmTask;
CustomTemporaryTable workOrderListTmp, workOrderListBuffer;
Integer workOrderCounter, workOrdersPerTask;
NoYesCombo skipExport;
workOrderCounter = 0;
// code here that sets skipExport and populates workOrderListTmp and workOrderCounter...tested and works correctly
if(this.isInBatch() && numberOfProcessingThreads > 1)
{
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
batchHeader.parmCaption('Multi thread work order confirm');
workOrdersPerTask = roundup(workOrderCounter/numberOfProcessingThreads, 1);
workOrderCounter = 0;
while select workOrderListTmp
{
workOrderBuffer.WorkOrderRecId = workOrderListTmp.WorkOrderRecId;
workOrderBuffer.insert();
workOrderCounter++;
if (workOrderCounter == workOrdersPerTask)
{
workOrderConfirmTask = new CustomConfirmTask();
workOrderConfirmTask.parmWorkOrderList(workOrderBuffer);
workOrderConfirmTask.parmSkipExport(skipExport);
batchHeader.addTask(workOrderConfirmTask, this.parmCurrentBatch().RecId);
workOrderCounter = 0;
workOrderBuffer = null;
}
}
if (workOrderCounter > 0)
{
workOrderConfirmTask = new CustomConfirmTask();
workOrderConfirmTask.parmWorkOrderList(workOrderBuffer);
batchHeader.addTask(workOrderConfirmTask, this.parmCurrentBatch().RecId);
}
batchHeader.save();
}
}
And here is the code for the class I’m making a task out of:
class CustomConfirmTask extends RunBaseBatch
{
CustomTemporaryTable workOrderList;
NoYesCombo skipExport;
#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
workOrderList,
skipExport
#ENDMACRO
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 parmWorkOrderList(CustomTemporaryTable _workOrderList)
{
workOrderList = _workOrderList;
}
public void parmSkipExport(NoYesCombo _skipExport)
{
skipExport = _skipExport;
}
public void run()
{
try
{
while (workOrderList)
{
// processing the work orders happens here
}
}
catch
{
info(strFmt("%1",xSession::xppCallStack()));
}
}
}
Thanks in advance for any help!