This is similar to this question, but I'm wondering about the object I'm sending into the Queueable Class.
Here's the Queuable Class (not much more than debug statements at this point)
public class CalloutLogger implements Queueable{
public transient HttpRequest req;
public CalloutLogger(httpRequest request){
system.debug('Queueable Class Constructor invoked....');
system.debug('Constructor Input "request": ' + request.toString());
req = request;
system.debug('Instance Var "req": ' + req.toString());
}
public void execute(QueueableContext context){
system.debug('CalloutLogger.execute invoked...');
system.debug('httpRequest.toString() : ' + req.toString());
}
}
Here's a demo Class that enqueues the job
public class DemoCallout {
public void simulatedCallout(){
//setup HttpRequest
HttpRequest req = new HttpRequest();
req.setEndpoint('http://www.notarealendpoint.com/service');
req.setMethod('GET');
//Examine operations....
system.debug('HttpRequest.toString() : ' + req.toString());
CalloutLogger logger = new CalloutLogger(req);
system.debug('logger var: ' + logger.req);
ID jobID = System.enqueueJob(logger);
system.debug('Enqueued Job with Id: ' + jobID);
}
}
And here's a bit of anonymous Apex that kicks it all off..
DemoCallout demo = new DemoCallout();
demo.simulatedCallout();
The anonymous Apex is successful with a debug log like this...
But the debug log for the Queuable Class give a null reference error for the HttpRequest object variable "req"...
Any suggestions? Is it even possible to pass an HttpRequest object to a Queuable Class (I'm going to want to pass the HttpResponse in too eventually!)
transient
keyword, I getLine: -1, Column: -1 System.SerializationException: Not Serializable: System.HttpRequest