Design Continuation Server in Salesforce

How to implement Continuation Server in Salesforce with the help of Action Function and Continuation Object

Continuation Server using ActionFunction in Salesforce
Continuation Server using Action Function in Salesforce

If you are new to Continuation Object in Salesforce then would suggest to read introduction post first. In last post, we discussed how to implement limitless chaining of Continuation Object using JavaScript remoting. In this post, we would try to achieve same, but instead of using JavaScript remoting, we would be using ActionFunction.

Why do we need chaining of Continuation Object

  • From Apex, we can only chain 3 Continuation Object
  • If we call API synchronously, chances are very high that it will run for more than 5 sec and contributing towards Concurrent Apex limit
  • Getting CPU timelimit error is also high
  • Making synchronous call also means risking scalability of Salesforce instance
  • You don’t want user to wait till call out completed, let them work and update user interface once response is received

Continue reading “Design Continuation Server in Salesforce”

Limitless Chaining of Continuation object in Salesforce

How to create a Continuation Server in Salesforce with the help of JavaScript remoting and Continuation Object

Chaining of Continuation Object in Salesforce
Chaining of Continuation Object in Salesforce

Around two years back, I posted an article on Continuation Object in Salesforce. As we know because of governor limits like concurrent Apex limit or CPU time limit errors, its always recommended to perform long running Apex process asynchronously. Processes specially like calling external API.

We can come up with multiple designs if number of APIs are less. However, you would risk scalability of Salesforce if number of APIs to be called is 10+. We cannot use chaining of continuation object directly as currently its limited to 3. If we call these API’s from Javascript (like using JavaScript remoting) then still we are using synchronous Apex which would be trade off for scalability.

What happens when we try to chain more than 3 Continuation Object call
What happens when we try to chain more than 3 Continuation Object in Salesforce

In Short, below are challenges in front of us

  • We need to call 10+ API from Visualforce
  • Cannot use chaining of Continuation Object as current chaining limit is 3
  • Cannot invoke each API from JavaScript remoting because it will be considered as Synchronous Apex

Continue reading “Limitless Chaining of Continuation object in Salesforce”