I have the following pseudo-code, and what I am attempting to do is chain queues that require call outs, I have read around and saw that you can't create another queue after a call out. I see the work around is you call a future
that queues up the next job. Is this the only way to do this? Does anyone know any other patterns? My comments below represent roughly my desired design.
Known limitation, idea is opened https://success.salesforce.com/ideaView?id=08730000000Dl7VAAS
Will accept Can we callout and chain a Queueable class? as an answer unless someone else has some ideas
public with sharing class OnBoardingFacade implements Queueable, Database.AllowCallOuts
{
// -------- Methods --------
public void execute(QueueableContext context)
{
if(first)
{
System.enqueueJob(new OnBoardingFacade());
System.debug('THE CONTEXT 1' + context);
//Callout 1, Sucessful go to second
}
else if(second)
{
System.enqueueJob(new OnBoardingFacade());
System.debug('THE CONTEXT 2' + context);
//Callout 2, Succesful go to third
}
else if(third)
{
System.enqueueJob(new OnBoardingFacade());
System.debug('THE CONTEXT 3' + context);
//Callout 3, Succesful finish.
}
}
}
enqueueJob
method performs dml. I would think if you just moveenqueueJob
to the end it should work, but I haven't tried it. – Adrian Larson♦ Aug 2 '16 at 20:02@future
or you can use Batchable, but you can't use another Queueable directly. My question also asked the same thing. Until we get word from salesforce that they'll allow it, we're stuck with what we have. – sfdcfox Aug 2 '16 at 20:11