public function index(Request $request): JsonResponse
{
$userId = auth()->id();
ExportCustomersJob::dispatch($request, $userId);
return $this->sendJsonResponse(...]);
}
I am using Redis for the queue. But as I see the json stored in Redis does not contain params from dispatch() method. Can somebody tell me please how to do it?
The purpose of queue jobs is to be independent and stateless. Without relying on the status of the active HTTP request, you need to possess all the information required to execute. you can pass the data you need to the job like so $data = $request->only(['name', 'email']); or $data = $request->all();
@Čamo the way queues operate in Laravel, queue jobs do not by default have access to the HTTP request object. A job is serialized and then unserialized for processing when it is sent to a queue. the HTTP request object contains a large amount of dynamic and non-serializable data, such as file handles, session data, and server context.
Extract the specific data you need from the request and pass it to the job.