開発者は、スケジュールされた Apex が DML 制限に達しているという問題を調査するように求められています。調査の結果、開発者は、スケジュールされた Apex によって処理されるレコードの数が最近 10,000 を超えて増加していることを発見しました。
制限例外エラーを解消するには開発者は何をすべきでしょうか?
正解:C
The best way to eliminate the limit exception error is to implement the Batchable interface. The Batchable interface allows the developer to create a class that can process large sets of data in batches, and execute logic for each batch of records. The developer can use the Database.executeBatch method to invoke the batch class, and specify the batch size and the scope of records to process. This way, the developer can avoid hitting the DML limits, as each batch of records will have its own set of governor limits. Using the @future annotation will not help, as it will only defer the execution of the method to a later time, but it will not split the records into batches, and it will still hit the DML limits. Implementing the Queueable interface will not help, as it will only allow the developer to chain asynchronous jobs, but it will not split the records into batches, and it will still hit the DML limits. Using platform events will not help, as they are used to communicate changes in data or processes across the system, but they will not split the records into batches, and they will still hit the DML limits. Reference: [Using Batch Apex], [Apex Developer Guide]