-2

what the code would look like if I wanted to implement batch functionality without implementing built-in Apex interface?

1
  • 1
    why you can't use built-in one? Commented Jun 16, 2020 at 7:19

2 Answers 2

6

The only options for implementing asynchronous processing of data available in the Salesforce platform using Apex, as covered in the documentation, are:

  • Queueable Apex - long running operation that can accept complex parameters and can chain**
  • Scheduled Apex - processing that is run to a specified schedule
  • Batch Apex - for long running operations that process large amounts of data and can chain
  • Future Methods - for long running processing where the results are not required synchronously, where callouts are required or where mixed DML issues need to be avoided

** there are specific limits on how much chaining you can implement (only start 1 new queueable from an existing queueable)

Each is specifically designed to fulfil a type of async processing. Thus, without really good reason, it generally doesn't make sense to implement a batch without using a Database.Batchable implementation. You could consider using a Queueable, but you will end up writing a lot more supporting code that you would not have to if you simply used Batchable and also will not be able to mimic the same behaviour as you might see for governor limit issues in the context of a Batchable.

4

What would it look like? It'd look like Daniel Peter's Hyperbatch. This is a process that runs in a way to process a large amount of data faster than normal Batchable calls, but the downside is that the UI must remain open while the batch runs. You could also use Queueable, which is a clean alternative to Batchable, including the ability to restart on failure (Finalizers, still in Pilot, so not production-ready yet).

Not the answer you're looking for? Browse other questions tagged .