Hi Deepak,
future method
A future method runs in the background, asynchronously. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you'd like to run in its own thread, on its own time.
Remember that any method using the future annotation requires special consideration because the method does not necessarily execute in the same order it is called.
The system executes the asynchronous call when it has available resources – this means that you can’t assume anything about when the call will be executed.
The asynchronous method executes in a different transaction context than the trigger. A failure of the callout will have no effect on the transaction controlling the trigger (i.e. changes will not be rolled back). You will have to build in suitable compensation logic yourself to account for any exceptions in the callout.
Future methods won’t necessarily execute in the same order they are called. In addition, it’s possible that two future methods could run concurrently, which could result in record locking if the two methods were updating the same record.
No more than 50 method calls per Apex invocation
The maximum number of future method invocations per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater
Keep the governor limits in mind when making callouts. We are constrained by the interface provided by the remote web service. If the remote web service were to provide any kind of batch processing interface, choose that instead of making individual calls. It helps avoid hitting the governor limits and will be more performant as well since there are fewer round trips to make.
Methods with the future annotation cannot be used in Visualforce controllers in either getMethodName or setMethodName methods, nor in the constructor.
@future(callout = true) means that the method has ability to invoke external web services.
Methods with the future annotation must be static methods
can only return a void type
The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types
Methods with the future annotation cannot take sObjects or objects as arguments.
You can invoke future methods the same way you invoke any other method. However, a future method can’t invoke another future method
Methods declared as future aren't allowed in classes that implement theDatabase.Batchable interface.
Methods declared as future can't be called from a batch Apex class.
The getContent and getContentAsPDFPageReference methods cannot be used in methods with the future annotation
Asynchronous calls, such as @future or executeBatch, called in a startTest, stopTest block, do not count against your limits for the number of queued jobs
To test methods defined with the future annotation, call the class containing the method in a startTest(), stopTest() code block. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously.
Queueable Apex
Non-primitive types: Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes.
Monitoring: When you submit your job by invoking the System.enqueueJob method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page, or programmatically by querying your record from AsyncApexJob.
Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful if you need to do some sequential processing.