There are some other posts regarding this but I guess, it need some further clarifications. It is mentioned in docs , though as a suboptimal solution for fire and forget pattern, that:

Similar to the solution for the Remote Process Invocation—Request and Reply pattern solution that specifies using a Visualforce page or Lightning component, together with an Apex callout. The difference is that in this pattern, Salesforce doesn’t wait for the request to complete before handing off control to the user.

After receiving the message, the remote system responds and indicates receipt of the message, then asynchronously processes the message. The remote system hands control back to Salesforce before it begins to process the message; therefore, Salesforce doesn’t have to wait for processing to complete

As per highlighted lines, Salesforce doesn't wait for request to complete. How that can happen? Suppose I click a button on VF Page and that initiated the API call.

  1. Does that mean I can take any further action on that page ? Next line in above paragraph, actually helps to reduce the confusion. It means, everything is blocked atleast till acknowledgement is received. After sending acknowledgement, remote system is free to do further processing via some other mechanism. is that understanding correct?

  2. But on going further, next line again introduces confusion. It says 'the remote system hands control back to Salesforce before it begins to process the message'. Now how does that happen? In my view, this can only be possible with help of 'continuation' feature, where callback is possible. But documentation doesn't mention that. In normal API calls, requester has to wait and transaction should be 'blocked', till atleast acknowledgement is received in my view, if this sub-optimal solution is chosen(of-course, we've better choices like platform events or oubound message which in my view, in true sense implements fire and forget pattern). But calling API via button click can't implement fire and forget pattern without continuation. Is that correct?

  3. this is already asked indirectly in point 2 . Still like to confirm, if continuation feature is implemented internally(Button click on vf page having controller), then page is not blocked, once call is made. I mean user should be free to do other things, even before response is received. isn't it?

  • The answer to your question lies in this innocuous statement: Control is handed back to the client either immediately or after positive acknowledgment of a successful hand-off to the remote system. That is, the client-side behavior depends on the implementation of the messaging protocol. As a side note, Fire and Forget originated in messaging systems. There it is understood that "forget" implies no obligation such as an ack of receipt from recipient back to originator. The authors of this Salesforce doc muddied these waters, meh.
    – identigral
    Jun 27 at 22:12

Query 1: Assuming that you are using http callouts, it is correct that everything is blocked at least till acknowledgement is received. In this pattern the external system confirms that the message was received but processes the message asynchronously after sending the acknowledgement of receipt of message. So receipt of acknowledgement is synchronous but processing of message is asynchronous.

Query 2: Even in continuation the page is blocked till you receive acknowledgment. The benefit of using continuation is that the callout does not count toward the Apex limit of 10 long running requests that last longer than five seconds.

Please refer to the following link for a better explanation of how continuation works. This clearly states that

"The action method creates a Continuation and returns it. After the request is sent to the service, the Visualforce request is suspended. The user must wait for the response to be returned before proceeding with using the page and invoking new actions. When the external service returns a response, the Visualforce request resumes and the page receives this response."


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.