function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chad Phillips 25Chad 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
VinayVinay (Salesforce Developers) 
Hi Chad,

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,
Krishna VKrishna V
Hi Chad, 

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