Activity Forums Salesforce® Discussions Difference between Queueable apex and future method ?

  • Difference between Queueable apex and future method ?

    Posted by Suraj on April 11, 2017 at 1:16 pm

    In future method we can't pass Sobject as a parameter but In Queueable we can pass Sobject. how?The Reason behind Future is that Object passed will get changed at the time of execution of Future Method which is still in Queueable?

    Manpreet replied 7 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Manpreet

    Member
    April 11, 2017 at 1:23 pm

    Hi suraj,

    All async code can run in to stale data. The difference between Batchable, Queueable, and Future methods is how they're designed to behave. Batchable calls were designed to allow for heavy asynchronous processing. But, it was the only asynchronous code at one point, and it was too "heavy" in terms of resource usage, and had a lot of baggage associated with it. It required a long time to process and was often used only to handle callouts or things that were slightly longer than a normal transaction could handle.

    So, next came future methods. Unlike Batchable methods, they were lighter on resources and perfect for doing that job that Batchable was doing before, but much more efficiently. Unfortunately, it was too efficient. You didn't know when the job was done (no Job ID), and it only had a limited amount of space to store data (the reason why it only accepted primitives and collections thereof).

    In response to feedback, a third version of asynchronous code was designed: Queueable. It was lighter than Batchable, but it gave you a Job ID and let you store complex data patterns. The lesser resources it used compared to batchable also meant higher limits. Queueable was meant to be a hybrid between the limited future methods and the resource-hungry Batchable interface.

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos