Why queuable apex accepts sobjects where as future methods doesn't?Why salesforce has introduced Queueable Apex. need some proper clarificationDifference between Queueable apex and future methodCan a future method conflict with a queuable method?Queuable Apex - chaining jobs vs calling other classes synchronouslyCallout Limits for future methods and queueable apexQueueable Apex in a Before Trigger
Graduate student with abysmal English writing skills, how to help
Why isn't pressure filtration popular compared to vacuum filtration?
Did the Vulgar Latin verb "toccare" exist?
Does Lufthansa weigh your carry on luggage?
Why weren't bootable game disks ever common on the IBM PC?
Why doesn't sea level show seasonality?
How is angular momentum conserved for the orbiting body if the centripetal force disappears?
How to properly say "bail on somebody" in German?
Single word for "refusing to move to next activity unless present one is completed."
How would vampires avoid contracting diseases?
Why are all my yellow 2V/20mA LEDs burning out with 330k Ohm resistor?
If a non-friend comes across my Steam Wishlist, how easily can he gift me one of the games?
How do you move up one folder in Finder?
Modulus Operandi
Has anyone in space seen or photographed a simple laser pointer from Earth?
Terry Pratchett book with a lawyer dragon and sheep
Would dual wielding daggers be a viable choice for a covert bodyguard?
How can I calculate the sum of 2 random dice out of a 3d6 pool in AnyDice?
Can the Mage Hand cantrip be used to trip an enemy who is running away?
Was I subtly told to resign?
Meaning of the negation in phrases like "не должен прочитать"
Received a dinner invitation through my employer's email, is it ok to attend?
How many hours would it take to watch all of Doctor Who?
What was the definition of "set" that resulted in Russell's Paradox
Why queuable apex accepts sobjects where as future methods doesn't?
Why salesforce has introduced Queueable Apex. need some proper clarificationDifference between Queueable apex and future methodCan a future method conflict with a queuable method?Queuable Apex - chaining jobs vs calling other classes synchronouslyCallout Limits for future methods and queueable apexQueueable Apex in a Before Trigger
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I was going through asynchronous apex and reading it made me confused at one point. In future methods, we cannot pass sojects for reasons future methods being executed at a later point of time, by the time it is executed the sboject data could be stale. But, at the same time, the more advanced queuable apex accepts sobjects. Why is it so? The same reason is applicable for queuable apex also right? kindly clarify.
asyncapexjob queueable-apex
add a comment |
I was going through asynchronous apex and reading it made me confused at one point. In future methods, we cannot pass sojects for reasons future methods being executed at a later point of time, by the time it is executed the sboject data could be stale. But, at the same time, the more advanced queuable apex accepts sobjects. Why is it so? The same reason is applicable for queuable apex also right? kindly clarify.
asyncapexjob queueable-apex
add a comment |
I was going through asynchronous apex and reading it made me confused at one point. In future methods, we cannot pass sojects for reasons future methods being executed at a later point of time, by the time it is executed the sboject data could be stale. But, at the same time, the more advanced queuable apex accepts sobjects. Why is it so? The same reason is applicable for queuable apex also right? kindly clarify.
asyncapexjob queueable-apex
I was going through asynchronous apex and reading it made me confused at one point. In future methods, we cannot pass sojects for reasons future methods being executed at a later point of time, by the time it is executed the sboject data could be stale. But, at the same time, the more advanced queuable apex accepts sobjects. Why is it so? The same reason is applicable for queuable apex also right? kindly clarify.
asyncapexjob queueable-apex
asyncapexjob queueable-apex
asked 9 hours ago
Jayakrishnan SalimJayakrishnan Salim
1084 bronze badges
1084 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The possibility of data going stale is not why future methods do not accept sObject parameters. Id values are future-compatible primitives and can also be stale, if, for example, the record is deleted prior to executing the future method.
All asynchronous code must be concerned about the validity of the data it is passed relative to the current state of the database. This is true across Batch, Queueable, and Scheduled Apex, and for future methods. There's no difference in that concern across all types of asynchronous processing in Salesforce (or, indeed, in other development environments).
Future methods and Queueable Apex simply are different implementations with different capabilities, future being rather older. Neither shields you against changes to the database state between enqueuing and execution, and the difference in accepted parameters isn't due to a difference in that respect.
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
add a comment |
Batchable, future, and queueable were basically three versions of the same feature request from customers. Initially, customers wanted a way to process bulk data asynchronously. We were given Batchable. Customers then complained that while batchable was great for mass processing, it was too "bulky" when all you wanted was simple asynchronous method calls, so we were given future.
Compared to batchable, you didn't need a separate top-level class, you didn't need to construct an object, you could use it up to 50 times per transaction, and you didn't need to call a special method to invoke it. However, it was also simplified, as you no longer received a "job Id", and you couldn't pass in complex object graphs (which improved efficiency and code design).
Queueable methods were implemented last, and became a hybrid of the two features, offering the ability to monitor jobs and handle complex objects, but without the overhead of Batchable, which required three asynchronous methods to process just a single record, which was why future methods were invented to begin with.
So basically, future methods can't handle them because customers of the time wanted a more lightweight asynchronous feature, and future was designed to address those needs in a way that allowed the best performance.
add a comment |
There are 2 kinds of Integrations.
1) That wants to know what was the State of the records at a given point in time when DML/Operation happened. When a transaction happened what is the state of the records, we need to sync it to the external system.
2) That wants to know what was the latest state of the record. It doesn't not matter how many updates have happened , when sending data to external system, we want latest data.
Back when there was no Queuable, for 1st type of Integration, people used to Serialize Sobjects into JSON string and pass it to the future method and do callout.
SF realized this is a proper use case, and started supported Passing of complex objects natively, now its upto devs to decide if they wanna query data or use serialized sobject data passed to Queueable.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f268911%2fwhy-queuable-apex-accepts-sobjects-where-as-future-methods-doesnt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The possibility of data going stale is not why future methods do not accept sObject parameters. Id values are future-compatible primitives and can also be stale, if, for example, the record is deleted prior to executing the future method.
All asynchronous code must be concerned about the validity of the data it is passed relative to the current state of the database. This is true across Batch, Queueable, and Scheduled Apex, and for future methods. There's no difference in that concern across all types of asynchronous processing in Salesforce (or, indeed, in other development environments).
Future methods and Queueable Apex simply are different implementations with different capabilities, future being rather older. Neither shields you against changes to the database state between enqueuing and execution, and the difference in accepted parameters isn't due to a difference in that respect.
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
add a comment |
The possibility of data going stale is not why future methods do not accept sObject parameters. Id values are future-compatible primitives and can also be stale, if, for example, the record is deleted prior to executing the future method.
All asynchronous code must be concerned about the validity of the data it is passed relative to the current state of the database. This is true across Batch, Queueable, and Scheduled Apex, and for future methods. There's no difference in that concern across all types of asynchronous processing in Salesforce (or, indeed, in other development environments).
Future methods and Queueable Apex simply are different implementations with different capabilities, future being rather older. Neither shields you against changes to the database state between enqueuing and execution, and the difference in accepted parameters isn't due to a difference in that respect.
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
add a comment |
The possibility of data going stale is not why future methods do not accept sObject parameters. Id values are future-compatible primitives and can also be stale, if, for example, the record is deleted prior to executing the future method.
All asynchronous code must be concerned about the validity of the data it is passed relative to the current state of the database. This is true across Batch, Queueable, and Scheduled Apex, and for future methods. There's no difference in that concern across all types of asynchronous processing in Salesforce (or, indeed, in other development environments).
Future methods and Queueable Apex simply are different implementations with different capabilities, future being rather older. Neither shields you against changes to the database state between enqueuing and execution, and the difference in accepted parameters isn't due to a difference in that respect.
The possibility of data going stale is not why future methods do not accept sObject parameters. Id values are future-compatible primitives and can also be stale, if, for example, the record is deleted prior to executing the future method.
All asynchronous code must be concerned about the validity of the data it is passed relative to the current state of the database. This is true across Batch, Queueable, and Scheduled Apex, and for future methods. There's no difference in that concern across all types of asynchronous processing in Salesforce (or, indeed, in other development environments).
Future methods and Queueable Apex simply are different implementations with different capabilities, future being rather older. Neither shields you against changes to the database state between enqueuing and execution, and the difference in accepted parameters isn't due to a difference in that respect.
answered 9 hours ago
David Reed♦David Reed
46.8k8 gold badges27 silver badges65 bronze badges
46.8k8 gold badges27 silver badges65 bronze badges
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
add a comment |
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
That was a good explanation @david. Thank you.
– Jayakrishnan Salim
9 hours ago
add a comment |
Batchable, future, and queueable were basically three versions of the same feature request from customers. Initially, customers wanted a way to process bulk data asynchronously. We were given Batchable. Customers then complained that while batchable was great for mass processing, it was too "bulky" when all you wanted was simple asynchronous method calls, so we were given future.
Compared to batchable, you didn't need a separate top-level class, you didn't need to construct an object, you could use it up to 50 times per transaction, and you didn't need to call a special method to invoke it. However, it was also simplified, as you no longer received a "job Id", and you couldn't pass in complex object graphs (which improved efficiency and code design).
Queueable methods were implemented last, and became a hybrid of the two features, offering the ability to monitor jobs and handle complex objects, but without the overhead of Batchable, which required three asynchronous methods to process just a single record, which was why future methods were invented to begin with.
So basically, future methods can't handle them because customers of the time wanted a more lightweight asynchronous feature, and future was designed to address those needs in a way that allowed the best performance.
add a comment |
Batchable, future, and queueable were basically three versions of the same feature request from customers. Initially, customers wanted a way to process bulk data asynchronously. We were given Batchable. Customers then complained that while batchable was great for mass processing, it was too "bulky" when all you wanted was simple asynchronous method calls, so we were given future.
Compared to batchable, you didn't need a separate top-level class, you didn't need to construct an object, you could use it up to 50 times per transaction, and you didn't need to call a special method to invoke it. However, it was also simplified, as you no longer received a "job Id", and you couldn't pass in complex object graphs (which improved efficiency and code design).
Queueable methods were implemented last, and became a hybrid of the two features, offering the ability to monitor jobs and handle complex objects, but without the overhead of Batchable, which required three asynchronous methods to process just a single record, which was why future methods were invented to begin with.
So basically, future methods can't handle them because customers of the time wanted a more lightweight asynchronous feature, and future was designed to address those needs in a way that allowed the best performance.
add a comment |
Batchable, future, and queueable were basically three versions of the same feature request from customers. Initially, customers wanted a way to process bulk data asynchronously. We were given Batchable. Customers then complained that while batchable was great for mass processing, it was too "bulky" when all you wanted was simple asynchronous method calls, so we were given future.
Compared to batchable, you didn't need a separate top-level class, you didn't need to construct an object, you could use it up to 50 times per transaction, and you didn't need to call a special method to invoke it. However, it was also simplified, as you no longer received a "job Id", and you couldn't pass in complex object graphs (which improved efficiency and code design).
Queueable methods were implemented last, and became a hybrid of the two features, offering the ability to monitor jobs and handle complex objects, but without the overhead of Batchable, which required three asynchronous methods to process just a single record, which was why future methods were invented to begin with.
So basically, future methods can't handle them because customers of the time wanted a more lightweight asynchronous feature, and future was designed to address those needs in a way that allowed the best performance.
Batchable, future, and queueable were basically three versions of the same feature request from customers. Initially, customers wanted a way to process bulk data asynchronously. We were given Batchable. Customers then complained that while batchable was great for mass processing, it was too "bulky" when all you wanted was simple asynchronous method calls, so we were given future.
Compared to batchable, you didn't need a separate top-level class, you didn't need to construct an object, you could use it up to 50 times per transaction, and you didn't need to call a special method to invoke it. However, it was also simplified, as you no longer received a "job Id", and you couldn't pass in complex object graphs (which improved efficiency and code design).
Queueable methods were implemented last, and became a hybrid of the two features, offering the ability to monitor jobs and handle complex objects, but without the overhead of Batchable, which required three asynchronous methods to process just a single record, which was why future methods were invented to begin with.
So basically, future methods can't handle them because customers of the time wanted a more lightweight asynchronous feature, and future was designed to address those needs in a way that allowed the best performance.
answered 9 hours ago
sfdcfoxsfdcfox
277k14 gold badges225 silver badges476 bronze badges
277k14 gold badges225 silver badges476 bronze badges
add a comment |
add a comment |
There are 2 kinds of Integrations.
1) That wants to know what was the State of the records at a given point in time when DML/Operation happened. When a transaction happened what is the state of the records, we need to sync it to the external system.
2) That wants to know what was the latest state of the record. It doesn't not matter how many updates have happened , when sending data to external system, we want latest data.
Back when there was no Queuable, for 1st type of Integration, people used to Serialize Sobjects into JSON string and pass it to the future method and do callout.
SF realized this is a proper use case, and started supported Passing of complex objects natively, now its upto devs to decide if they wanna query data or use serialized sobject data passed to Queueable.
add a comment |
There are 2 kinds of Integrations.
1) That wants to know what was the State of the records at a given point in time when DML/Operation happened. When a transaction happened what is the state of the records, we need to sync it to the external system.
2) That wants to know what was the latest state of the record. It doesn't not matter how many updates have happened , when sending data to external system, we want latest data.
Back when there was no Queuable, for 1st type of Integration, people used to Serialize Sobjects into JSON string and pass it to the future method and do callout.
SF realized this is a proper use case, and started supported Passing of complex objects natively, now its upto devs to decide if they wanna query data or use serialized sobject data passed to Queueable.
add a comment |
There are 2 kinds of Integrations.
1) That wants to know what was the State of the records at a given point in time when DML/Operation happened. When a transaction happened what is the state of the records, we need to sync it to the external system.
2) That wants to know what was the latest state of the record. It doesn't not matter how many updates have happened , when sending data to external system, we want latest data.
Back when there was no Queuable, for 1st type of Integration, people used to Serialize Sobjects into JSON string and pass it to the future method and do callout.
SF realized this is a proper use case, and started supported Passing of complex objects natively, now its upto devs to decide if they wanna query data or use serialized sobject data passed to Queueable.
There are 2 kinds of Integrations.
1) That wants to know what was the State of the records at a given point in time when DML/Operation happened. When a transaction happened what is the state of the records, we need to sync it to the external system.
2) That wants to know what was the latest state of the record. It doesn't not matter how many updates have happened , when sending data to external system, we want latest data.
Back when there was no Queuable, for 1st type of Integration, people used to Serialize Sobjects into JSON string and pass it to the future method and do callout.
SF realized this is a proper use case, and started supported Passing of complex objects natively, now its upto devs to decide if they wanna query data or use serialized sobject data passed to Queueable.
answered 9 hours ago
Pranay JaiswalPranay Jaiswal
21.7k5 gold badges33 silver badges71 bronze badges
21.7k5 gold badges33 silver badges71 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f268911%2fwhy-queuable-apex-accepts-sobjects-where-as-future-methods-doesnt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown