MULE BATCH JOB
(PART 3)
These two steps we have illustrated how to process records and handle failures in a batch job. another special case I have noticed that worths talking about, for instance in case during the input phase no database connection could be established because of the wrong database url the following exception is caught by the default exception strategy as depicted within the following:
INFO 2014-12-12 11:04:24,212[[batch-job-demo].start-batch-job.stage1.02]
com.mulesoft.module.batch.engine.DefaultBatchEngine: Starting input phase
INFO 2014-12-12 11:04:24,222[[batch-job-demo].start-batch-job.stage1.02]
org.mule.api.processor.LoggerMessageProcessor:
Start getting users records - connecting to database using URL:
ERROR 2014-12-12 11:04:24,263 [[batch-job-demo].start-batch-job.stage1.02]
org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : null (java.lang.NullPointerException).
Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.module.db.internal.domain.connection.DefaultDbConnection:99 (null)
--------------------------------------------------------------------------------
In this case, the batch process will continue to the end that is the on complete phase, this is a very important if we need to generate a report at the end of the batch process even with 0 records processed etc... and the exception that occurred. The following is the output result within the on complete phase picked from the logging:
INFO 2014-12-12 11:04:24,287 [[batch-job-demo].start-batch-job.stage1.02]
com.mulesoft.module.batch.engine.DefaultBatchEngine:
Starting execution of onComplete phase for instance 09b38430-8474-11e4-9c5c-0a0027000000
of job users-accounts-batch-job
INFO 2014-12-12 11:04:24,371 [[batch-job-demo].start-batch-job.stage1.02]
org.mule.api.processor.LoggerMessageProcessor:
on-complete payload: BatchJobInstanceId:09b38430-8474-11e4-9c5c-0a0027000000
Number of TotalRecords: 0
ProcessedRecords: 0
Number of sucessfull Records: 0
Number of failed Records: 0
ElapsedTime in milliseconds: 0
InpuPhaseException com.mulesoft.module.batch.exception.BatchException:
null (java.lang.NullPointerException). Message payload is of type:
String (org.mule.api.MessagingException)
LoadingPhaseException: null
CompletePhaseException: null
Here in this phase, it appears clearly that 0 records have been processed, and this happened because of the database connection exception that occurred during the input phase as it is shown by the InputPhaseException. This kind of exception handling is useful if the requirements state to have a report at the end of the batch job process indicating the number of records processed along with the failed and successful ones.
ResponderEliminarthe blog is good and Interactive it is CANONICAL DATA MODEL is useful for students and Mulesoft Developers for more updates on Mulesoft follow the link
mulesoft Online training
For more info on other technologies go with below links
Python Online Training
tableau online training hyderabad
ServiceNow Online Training