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
Muthouazhagi DhanapalMuthouazhagi Dhanapal 

Error Handling and recovery during Salesforce integration

Hi ,

I am new to Salesforce development, and I am doing my first project on integrating Salesforce and external systems. My remote system will use the REST API to create/update/delete data in Salesforce. I read the following in the Salesforce document :

"Error handling—All the remote call-in methods, standard or custom APIs, require the remote system to handle any subsequent errors, such as timeouts and the management of retries. Middleware can be used to provide the logic for error handling and recovery.

• Recovery—A custom retry mechanism needs to be created if quality-of-service requirements dictate it. In this case, it’s important to ensure idempotent design characteristics. Platform event enables subscribers to use the replay ID to fetch messages within a certain time period after those messages were published."

Can anyone please tell me what kind of errors and recovery I will have to take care of in my remote system? Any links will be very helpful for me. I am not using any middleware, in what cases should I consider using a middleware. 

Best Answer chosen by Muthouazhagi Dhanapal
Abdul KhatriAbdul Khatri
Hi Muthouazhagi,

How your remote system is planning to use the Salesroce REST APIs to perform DML operations in Salesforce?

There are couple of tools can be used which has built in mehcanism for retry in case of any failures.
  • Mulesoft
  • Boomi
  • Microsoft Azure
If you are planning to custom create build something like .Net API, Nodejs etc. then I will think you need to possibly build something to capture those failures into some Database and build some kind of reprocessing to process those fail records.

Please keep in mind in that case I believe you need to keep in mind the API Request Limit (What is the Edition of your Production Org, Professional, Enterprise, Unlimited etc)

Another suggestion is to use Pubsub mechanism (recommended) using Platform Events. In that case you need to do the following
  • Create Platform Events with possible mode like create, update, delete etc. so you know the remote system subscript for what.
  • In this scenarion the remote system will subscribe and publish the event to get the payload so you can process on that payload
  • Even the above tool mentioned may have something for the same, you can take a look.

All Answers

RituSharmaRituSharma
If other system is consuming salesforce standard rest APIs to create/edit/delete SF data then error handling and retry mechanism has to be built by that system. SF will return standard HTTP error codes and accordingly other system will need to develop error handling and retry mechanism.

Standard Rest APIs
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_what_is_rest_api.htm

Error Codes
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm
Muthouazhagi DhanapalMuthouazhagi Dhanapal

Thank you very much ! 

Do we definitely need a middleware to handle all these ? or is it fine to handle it in the remote system itself?

Abdul KhatriAbdul Khatri
Hi Muthouazhagi,

How your remote system is planning to use the Salesroce REST APIs to perform DML operations in Salesforce?

There are couple of tools can be used which has built in mehcanism for retry in case of any failures.
  • Mulesoft
  • Boomi
  • Microsoft Azure
If you are planning to custom create build something like .Net API, Nodejs etc. then I will think you need to possibly build something to capture those failures into some Database and build some kind of reprocessing to process those fail records.

Please keep in mind in that case I believe you need to keep in mind the API Request Limit (What is the Edition of your Production Org, Professional, Enterprise, Unlimited etc)

Another suggestion is to use Pubsub mechanism (recommended) using Platform Events. In that case you need to do the following
  • Create Platform Events with possible mode like create, update, delete etc. so you know the remote system subscript for what.
  • In this scenarion the remote system will subscribe and publish the event to get the payload so you can process on that payload
  • Even the above tool mentioned may have something for the same, you can take a look.
This was selected as the best answer
Muthouazhagi DhanapalMuthouazhagi Dhanapal

Hi Abdul, Thank you very much for the detailed solutions.

Please correct me if I am wrong, 
For remote call-in pattern, Platform events support only create operation right? I read that in Integration pattern documentation (Attached to this message).User-added image

RituSharmaRituSharma
It's ideal to use middleware. It's not easy to implement error handling, logging and retry mechanism.
Abdul KhatriAbdul Khatri
Hi Muthouazhagi

Yes, In pubsub pattern, platform events only work on AfterInsert because whenever event publish it creates a record for that event define through Platform events.

@RituSharma
Please help him with some more details about what middleware, what do you have in your mind and how he can use it without having any kind of logging, error handling and retry mechanism so we all can get educated.