1

I've got problem with executing deployment jobs inside queueable instance.

Background:

  • Exchange rates data is divided between two endpoints a and b. That's why I need to make a callout twice.
  • requestExchangeRates future method that fetches exchange rates and performs enqueueDeployment to update/create exchange rate metadata records.
public class ExchangeRatesService implements Queueable {
    
    private String tableName;
    private Boolean secondCall;
    
    public ExchangeRatesService(String tableName, Boolean secondCall) {
        this.tableName = tableName;
        this.secondCall = secondCall;
    }
    
    public void execute(QueueableContext context) {
        if(secondCall) return;
        if(tableName == 'a') {
            requestExchangeRates(tableName);
            if(!secondCall) {
                System.enqueueJob(new ExchangeRatesService('b',true));   
            }
        } else if(tableName == 'b') {
            requestExchangeRates(tableName);
            if(!secondCall) {
                System.enqueueJob(new ExchangeRatesService('a',true));   
            }            
        } else {
            //Unrecognized 
        }
    }
}

Result: No deployment job is performed, all related queueable and future jobs are completed successfully. How to perform this scenario? is it possible?

3
  • what do you mean by a "deployment job"?
    – cropredy
    Mar 1 at 23:10
  • How certain are you that the requestExchangeRates future method ran in addition to the re-enqueued ExchangeRatesService Queueable job? Normally you want to avoid multiple async branches coming out of a Queueable Job execution. Salesforce will explicitly stop you from launching multiple queueable jobs and may be putting the future method in the same limitation. I've definitely long chains of single child queueables and future methods in this way. Mar 2 at 0:46
  • Does an anonymous Apex call to requestExchangeRates('a'); produce the expected custom metadata deployment? Mar 2 at 0:47

Your Answer

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

Browse other questions tagged or ask your own question.