...
Code Block |
---|
theme | Eclipse |
---|
language | java |
---|
title | multithreadProcess methodbillAccounts |
---|
collapse | true |
---|
|
public class CRMProcessAccountBilling extends CRMProcessRunBean {
...
public void billAccounts(Integer threads,String logFileName) throws Exception
{
ResultSetUtil billableAccounts = getBillableAccounts();
Integer threads = getNumberOfThreads();
Boolean logFailed = new Boolean(true);
Boolean logSuccess = new Boolean(true);
if (billableAccounts != null && billableAccounts.getRowCount()>0)
{
EJBThreadPoolExecutor threadExecutor=new EJBThreadPoolExecutor(getCRMSessionHandle(), "ejb/CRMProcessBillAccount", "billAccount",threads, billableAccounts.getRowCount(), 10, TimeUnit.SECONDS, logFileName);
while (billableAccounts.next())
{
String accRecID = billableAccounts.getString("ACCRECID");
Object[] otherparams = new Object[] {accRecID};
threadExecutor.submitTask(otherparams);
}
threadExecutor.shutdown();
}
}
...
} |
Note that the default transaction timeout value of the main process class, which in this case is CRMProcessAccountBillingBean, must be increased. For more information on setting EJB transactions timeout value go to Change EJB Transaction Timeout.
Code Block |
---|
theme | Eclipse |
---|
language | java |
---|
title | billAccount |
---|
collapse | true |
---|
|
public class CRMProcessBillAccountextends CRMProcess {
...
@EJB private CRMProcessLog processLog;
...
public void billAccount(String accrecID,
CRMDOProcessRunLog processRun,
Boolean logSuccess,
Boolean logFailed) throws Exception
{
try
{
}
catch(Exception e)
{
processLog.createEntityLogRecord(processRun.getId(), accrecID, "ACCOUNTSRECEIVABLE", ProcessRunLogEntityStatus.FAILED.toString(), e.getClass().getSimpleName(),
ExceptionUtil.getStackTrace(e),logFailed,logSuccess);
getSessionContext().setRollbackOnly();
}
}
...
} |