1

We have a a service class where we use as repository/factory for specific external endpoint. One of those endpoint has a method which takes sometime and for that reason we get a timeout exception since we are making a sync call.

We started to use Apex Continuation but we get the following error:

Apex methods for continuation can not be invoked from a non-continuation action.

There is not so much documentation, we think the cause of the error it's because the invocation of the service we have implemented.

@AuraEnabled(continuation=true cacheable=true)
public static Object updateListSubscription(String subscriptionList, String conctactId){

    HttpRequest request = HTTP_InformaticaInterface.UpdateListSubscription(conctactId, subscriptionList);
    Continuation cont = new Continuation(60);
    cont.state = cont.addHttpRequest(request);
    cont.ContinuationMethod = 'updateListSubscriptionCallback';
    return cont;
}

@AuraEnabled(cacheable=true)
public static Boolean updateListSubscriptionCallback(List<String> labels, Object state){
    HttpResponse response = Continuation.getResponse(labels[0]);
    return response.getStatusCode() == 200;
}

how can we use the "UpdateListSubscription" method in the context of a continuation method?

3
  • So UpdateListSubscription method is called from AUra component's jS right? Jul 8, 2019 at 11:41
  • Yes It's called from the JS Jul 8, 2019 at 12:27
  • I tried your code and was able to do all, witthout any issues Jul 8, 2019 at 13:05

1 Answer 1

2

LWC import must get Apex method from apexCountinuation but not apex resource.

'@salesforce/apexContinuation/ApexClass.ClassMethod';

not

'@salesforce/apex/ApexClass.ClassMethod';

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .