Apex Publish Callback Limits
Description | Limit |
---|---|
Maximum cumulative usage of all publish callbacks in the last 30 minutes | 5 MB |
Maximum number of times a publish callback method implementation can call EventBus.publish with a callback recursively. | 10 |
The publish callback size used in the callback allocation is the size of the objects contained in a callback class instance, such as the class variable objects. It isn’t the length of the Apex class in characters. For example, in the FailureCallbackWithCorrelation class in Example: Publish Callback Class That Correlates Callback Results with Event Messages, the objects that contribute to the size counted in the allocation are these class variables: MAX_RETRIES, retryCounter, and uuidMap. The cumulative usage is the sum of the sizes of callback instances that were executed in the last 30 minutes. If you hit the callback size limit, try to reduce the size of the objects stored in your callback class through the class variables. Alternatively, limit the number of retried callback executions or wait before using callbacks again. The callback limit is a rolling limit and counts usage in the last 30 minutes, so usage can decrease after some time has passed. Usage is updated every time you publish an event with a callback.
To monitor the usage of all publish callbacks in the last 30 minutes, make a REST API call to the limits resource, and inspect the PublishCallbackUsageInApex value in the returned response. Make a GET request to:
/services/data/v63.0/limits
The PublishCallbackUsageInApex value in the returned response looks similar to this example. The PublishCallbackUsageInApex value returns the maximum usage and the remaining usage size in bytes.
"PublishCallbackUsageInApex" : {
"Max" : 5242880,
"Remaining" : 4011396
}