You need to sign in to do that
Don't have an account?
Chad Phillips 25
Retry platform event with future callout
Hi,
I have a platform event. When the platform event trigger fires, it does a callout to a 3rd party REST API. The Apex method is marked @future(callout = true). If the 3rd party REST API has a timeout, I would like to have the platform event retry.
The issue is since the code is @future(callout = true), the platform event fires and doesn't wait to see if the callout completes.
Is there a way to catch the timeout in my Apex code and have it cause the platform event to later retry?
thank you
I have a platform event. When the platform event trigger fires, it does a callout to a 3rd party REST API. The Apex method is marked @future(callout = true). If the 3rd party REST API has a timeout, I would like to have the platform event retry.
The issue is since the code is @future(callout = true), the platform event fires and doesn't wait to see if the callout completes.
Is there a way to catch the timeout in my Apex code and have it cause the platform event to later retry?
thank you
You can use EventBus.RetryableException and when the system RetryableException is thrown the Platform will automatically retry a batch events after period of time, up to 9 times.
Check below reference for implementing retry logic
https://andyinthecloud.com/category/platform-events/
https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_subscribe_apex_refire.htm
Please mark as Best Answer if above information was helpful.
Thanks,
Can you expand a little bit on your problem? As in, how is this call out being kicked off, do you have a trigger on the platform event that is kicking off the future method that does the rest call?
Thanks