Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

On the last step, the CRMProcessRunBean mentioned in the module.xml as additional process need to be implemented whilst the method executeMessageProcess which executes the process runs via threats mechanism like in Implement a Multithreaded Process section. Firstly, process run method saves the action inputs. Then each process run request processed from a thread and if procedure works correctly, the next process run prepares to been processed and the current one saved as completed. On the other hand, if something goes wrong, the current process run is saved as failed and moves to process the next request. This procedure continues until all the process run requests pass from the multi-threading mechanism. As a result, all the successful and failed process runs are illustrated in the summary page image above. Also, below is illustrated the example of the multi-threaded method implemented:

 

Code Block
themeEclipse
languagejava
titleexecuteMessageProcess.java
collapsetrue
public class CRMProcessSmsRunBean extends CRMProcessRunBean { 

	@EJB private CRMBOExsetSmsWebServiceProviderBean exsetProviderBean;
	@EJB private smsInfocasMessageRunDefinitionXMLUtilBean messageRunDefinitionXMLUtilBean;

...

	public void executeInfocasMessageProcess(CRMDOProcessRunLog processRun) throws Exception {
        
        CRMDOProcessRunDefinition processRunDefinition = processRun.getProcessRunDefinition();
        smsInfocasMessageRunDefintion  infocasMessageRunDefinition= new smsInfocasMessageRunDefintion();
        infocasMessageRunDefinition.setProcessRunDefinition(processRunDefinition);
        
        infocasMessageRunDefinition = messageRunDefinitionXMLUtilBean.loadProcessingRunDefinition(infocasMessageRunDefinition);
        CRMDOProvProvider provProvider = exsetProviderBean.loadEffective();
        provProvider = exsetProviderBean.setObjectsFromXML(provProvider);
        
        processRun.setStatus(ProcessRunLogStatus.IN_PROGRESS);
        processRun.setStartDate(getCurrentDate());
        
        processRunLogBean.save(processRun);
        
        Boolean processComplete = new Boolean(false);
        JDBCConnection connection= null;
        try
        {
            // action inputs
            Integer period = infocasMessageRunDefinition.getBroadcastPeriod();
            Integer interval = infocasMessageRunDefinition.getBroadcastInterval();
            CRMDOCommunicationQueueExternalSystem comQueueExternalSystem = infocasMessageRunDefinition.getCommunicationQueueExternalSystem();
            
            Boolean processImmediately = (
                    infocasMessageRunDefinition.getProcessImmediately()!=null && 
                            infocasMessageRunDefinition.getProcessImmediately().equals(1)) ? true : false;
            
            String host = provProvider.getEndPoint();
            String username = provProvider.getUserName();
            String password = provProvider.getPassword();
            String databaseName=provProvider.getDestinationID();
            int port=1521;
            
            if(provProvider.getDestinationPort()!=null && provProvider.getDestinationPort().intValue()>0)
            {
                port=provProvider.getDestinationPort().intValue();
            }
            
            connection=new JDBCConnection(DatabaseType.oracle, databaseName, true, host, port, username, password);
            
            
            Integer threads = getNumberOfThreads();
            
            // create provisioning requests
            submitMessageRequests(
                    processRun,
                    threads,
                    provProvider,
                    comQueueExternalSystem,
                    period,
                    interval,
                    processImmediately,connection);
            if(connection!=null)
                connection.close();
            
            processComplete = new Boolean(true);
        }
        catch (Exception e)
        {
            saveEntityLogRecord(
                    processRun,
                    "", 
                    "",
                    ProcessRunLogEntityStatus.FAILED, 
                    e.getClass().getSimpleName(), 
                    ExceptionUtil.getStackTrace(e));
            processRun.setEndDate(getCurrentDate());
            processRun.setStatus(ProcessRunLogStatus.FAILED);
            
            processRunLogBean.save(processRun);
            
            processRun = saveNextProcessRun(processRun);
            
            if(connection!=null)
                connection.close();
        }
        
        if (processComplete)
        {
            processRun.setStatus(ProcessRunLogStatus.COMPLETED);
            processRun.setEndDate(getCurrentDate());
            processRun = saveNextProcessRun(processRun);
            
            processRunLogBean.save(processRun);
        }
    }

...

}