Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Continuation Class
Namespace
Example
For a code example, see Make Long-Running Callouts from a Visualforce Page.
Continuation Constructors
The following are constructors for Continuation.
Continuation(timeout)
Signature
public Continuation(Integer timeout)
Parameters
-
timeout:
Type: Integer
The timeout for this continuation in seconds.
Continuation Properties
The following are properties for Continuation.
continuationMethod
state
Signature
public Object state {get; set;}
Property Value
Type: Object
Example
This example shows how to save state information for a continuation in a controller.
1// Declare inner class to hold state info
2private class StateInfo {
3 String msg { get; set; }
4 List<String> urls { get; set; }
5 StateInfo(String msg, List<String> urls) {
6 this.msg = msg;
7 this.urls = urls;
8 }
9}
10
11// Then in the action method, set state for the continuation
12continuationInstance.state = new StateInfo('Some state data', urls);Continuation Methods
The following are methods for Continuation.
addHttpRequest(request)
Signature
public String addHttpRequest(System.HttpRequest request)
Parameters
-
request:
Type: HttpRequest
The HTTP request to be sent to the external service by this continuation.
Return Value
Type: String
A unique label that identifies the HTTP request that is associated with this continuation. This label is used in the map that getRequests() returns to identify individual requests in a continuation.
Usage
You can add up tothree requests to a continuation.
getRequests()
Signature
public Map<String,System.HttpRequest> getRequests()
Return Value
Type: Map<String,HttpRequest>
A map of all requests that are associated with this continuation. The map key is the request label, and the map value is the corresponding HTTP request.
getResponse(requestLabel)
Signature
public static HttpResponse getResponse(String requestLabel)
Parameters
-
requestLabel:
Type: String
The request label to get the response for.
Return Value
Type: HttpResponse
Usage
The status code is returned in the HttpResponse object and can be obtained by calling getStatusCode() on the response. A status code of 200 indicates that the request was successful. Other status code values indicate the type of problem that was encountered.
Sample of Error Status Codes
When a problem occurs with the response, some possible status code values are:
- 2000: The timeout was reached, and the server didn’t get a chance to respond.
- 2001: There was a connection failure.
- 2002: Exceptions occurred.
- 2003: The response hasn’t arrived (which also means that the Apex asynchronous callout framework hasn’t resumed).
- 2004: The response size is too large (greater than 1 MB).