0

I was wondering if someone could help me to understand the Laravel 4 queue system.

I want to use it for background processing of CSV files, so that the user can upload the CSV file and continue using the system while the CSV is doing what it needs to do in the background, but it doesnt seem to be working.

In my controller i have the following:

// Push the import into the queue
Queue::push('QueueController@importCSV', array('filename' => $filename, 'fileext' => $fileExt));

// Everything sorted, return success
return Response::json('success', 200);

In my QueueController is all the logic to import the CSV data.

My problem is that when i push to the queue using the above code, it waits for that import to finish until it returns the response, as the CSV's are quite large, it will take minutes before i get the success response.

I thought if you push something to the queue, it does it in the background while the user continues using the system.

Could someone tell me where im going wrong and maybe help out with what i need to do.

Cheers,

3
  • You cant 'queue' an upload. It sounds like what you want to do is an ajax upload. Commented Dec 5, 2014 at 4:33
  • Im not queuing the uploading, im queuinng the processing of the CSV ... The upload gets done before the push command is in Commented Dec 5, 2014 at 4:41
  • 1
    Which queue system are you using in your config? It cannot be 'sync' - must be redis, beanstalkd etc Commented Dec 5, 2014 at 6:38

1 Answer 1

1

If you are talking about the time to upload the file, it is not a Queue issue. You would need to use something as AJAX and he user probably won't be able to leave the page anyway.

If you are talking about actual time to handle the CSV AFTER it is uploaded, you also need to make sure that you have Beanstalkd working to handle the queue.

Try adding a delay of a few minutes and see if the user will have a result while the queue is not processed yet:

$date = Carbon::now()->addMinutes(15);
Queue::later($date, 'SendEmail@send', array('message' => $message));

Reference: http://laravel.com/docs/4.2/queues

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.