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?

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

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

'@salesforce/apexContinuation/ApexClass.ClassMethod';

not

'@salesforce/apex/ApexClass.ClassMethod';

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.