Can we send SObject as params to Queueable Apex class?

Let's see if we can send SObject as params to Queueable Apex class.

Queueable Apex is the lighter version of Batch Apex at the same time more flexible than Future method.

Check the difference between Queueable Apex and Future annotation.

Apart from all the differences one of the main difference between both the entities is, in future method we cannot send SObjects as params. We can only send primitive data types (here we looked at how to send complex data types as params to future method).

Whereas in Queueable Apex we can send Sobjects as params.

Let's look at some snippet!

public class LoadContactsQueueable implements Queueable {

	Account a;
	public LoadContactsQueueable(Account a){
    	this.a = a;
    }

    public void execute(QueueableContext context) {
        Contact con = new Contact(Name='Acme',Phone='(415) 555-1212');
        con.website = a.website;
        con.AccountId = a.Id;
        
        insert con;        
    }
}
Queueable Class accepting Sobject params

Hope this is helpful!