I have a simple Platform Event called Timesheet_Approval__e
.
As a test, I publish a batch of 1000 events with this anonymous apex:
List<Timesheet_Approval__e> approvals = new
List<Timesheet_Approval__e>();
for (Integer n=0; n<1000; n++) {
approvals.add(new Timesheet_Approval__e());
}
EventBus.publish(approvals);
In the subscriber trigger, there will be some fairly heavy-duty processing to be done, but for the moment I just have the following:
trigger Timesheet_Approval on Timesheet_Approval__e (after insert) {
System.debug('*** APPROVALS '+Trigger.new.size());
}
so I can see how many events have been received.
I note that the initial batch of 1000 events is split into smaller batches of variable size, generally around 100, and the subscriber was triggered 11 times. The total number of events received is 1000, as expected.
Is there any way of controlling how many events are received in a single trigger invocation? I want to limit it because of the processing I need to to, to avoid hitting governor limits.
Any advice would be appreciated.