Git Product home page Git Product logo

sfdc-queueablemanager's Introduction

SFDC Queueable Manager

Queueable orchestration in Salesforce.com platform.

Overview

The Queueable interface in Salesforce's platform allows code execution in an asynchronous fashion while providing a number of advantages over future calls. But, like everything in Salesforce, comes with a number of limitations. One challenge is the orchestration of calls, specially from other async contextes like batch apex and queueable itself, which in some instances result in "too many queueable jobs added to the queue:" exception. The problem is that the number of queueable jobs you can add depends on the context, where in syncrounous context you can add up 50 jobs, in async context you can only call one additional job.

Queueable Manager comes to the rescue; It tracks queueu availability on all contextes, making sure your code is always execute without issues. While queue space is available, your jobs will be enqueued as usual, then executed synchrously when resources are consumed. It also keeps track of which jobs have have already been executed during the transaction, helping avoid enqueuing the same job more than once.

Usage

Use QueueableManager in place of system.enqueueJob. Following example enqueues your job in the system queue:

SomeQueueable q = new SomeQueueable();
q.someValue = 1;
QueueableManager.enqueueAndExecute('SomeQueueableInstance1', q);

Another option is to add multiple jobs to the queue and then executing all of them, for a better control of when your jobs are actually enqueued:

SomeQueueable q1 = new SomeQueueable();
q1.someValue = 1;
QueueableManager.enqueueJob('SomeQueueableInstance1', q1);
///Something else can be done here
//Then at some point during transaction add another job
SomeQueueable q2 = new SomeQueueable();
q2.someValue = 2;
QueueableManager.enqueueJob('SomeQueueableInstance2', q2);
///Something more here
//Then execute (system.enqueue) all jobs previously added to the queue
QueueableManager.executeAll();

sfdc-queueablemanager's People

Contributors

harrymendez23 avatar

Stargazers

TOTALLYMAJOR avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.