Hi Team,
I have created multi threaded batch job to process the imported records from custom table, as per my logic I am creating threads according to the Journal numbers.
But the issue is I am not able to execute all the thread at once, system is executing some threads first and then waiting for to start next thread unless previous all should get ended.
Below is the code -
void run()
{
MTDEVTutorialBatchMultipleThreadBaseAllInsert multiThreadTask;
MTCentralDataHubTable centralDataHubTable;
while select LedgerJournalId from centralDataHubTable
group by LedgerJournalId
where centralDataHubTable.OperationType == str2int(operationType)
&& centralDataHubTable.Processed == NoYes::No
{
try
{
if(this.isInBatch())
{
if(!batchHeader)
{
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
}
batchHeader.parmCaption("Import vendor invoice journal");
multiThreadTask = new MTDEVTutorialBatchMultipleThreadBaseAllInsert();
multiThreadTask.parmCentralDataHubTable(centralDataHubTable.data());
batchHeader.addRuntimeTask(multiThreadTask, this.parmCurrentBatch().RecId);
}
else
{
throw Error("Execution must be scheduled in batch.");
}
}
catch (Exception::DuplicateKeyException)
{
retry;
}
catch(Exception::DuplicateKeyExceptionNotRecovered)
{
warning("Not recovered");
}
catch
{
info(strFmt("%1",xSession::xppCallStack()));
}
}
if(batchHeader)
{
// save the batchheader with added tasks
batchHeader.save();
}
}Batch Job screen:
I am expecting like all thread should start at once.
Please suggest me the best approach to write this logic and how can i increase the performance.


Report
All responses (
Answers (