This Firing Platform Events from Batch Apex documentation largely discusses automatically publishing a BatchApexErrorEvent
on an unhandled exception:
If the start, execute, or finish method of a batch Apex job encounters an unhandled exception, a BatchApexErrorEvent platform event is fired. For more details, see BatchApexErrorEvent.
if the class implements Database.RaisesPlatformEvents
. So at first sight, this is a switch to turn on the automatic conversion of exceptions to the BatchApexErrorEvent
Platform Event in Batchables to improve the error reporting.
My question is whether this interface also needs to be implemented to allow other Platform Events to be explicitly published via an EventBus.publish
call? This is a different scenario not discussed in the linked documentation.
(A precedent here is that to make callouts you must implement Database.AllowsCallouts
.)