Email notification of failed records from Execute / Finish methods ?
We can send from any of the method.But ideal way is to send from Finish method.Why its recommended to send notifications from Finish method ?
This finish method called after all batches are processed,It means only one time execution for complete job.
What is the use of Database.Stateful ?
Batch Apex is by default Stateless.
To maintain the state across all transactions we can implement this interface 'Database.Stateful'.
Ex:
Capturing the failed record information in Execute method between all transactions and assigning to member. And use that member in Finish method.
Note : Only instance member variable retain their values between transaction.
Ex: Static member ,Which will not retain value between transaction.
Very Helpful.
ReplyDeleteVery Helpful.. beautifully explained this blog clear my all doubts.. related to batch class
ReplyDeletecan you please add DT_UTILITY class
ReplyDelete