miwal's avatar
Level 11

What does laravel store in the payload field of the jobs table for a queued mail?

This is a simple question for someone who is already using laravel queues... It's just a question more or less of fact.

I haven't set up the laravel queue system, I've been relying on a rather, I admit, round about method of checking for evidence of mail that needs sending once an hour (on a one off dyno on heroku), rather than actually using any kind of queue.

I'm planning to transition to my own custom queued_mail table, because this will make it a lot more straightforward to schedule mails to be sent incorporating a specified time delay. (It's possible with my fully normalised current method, but I don't look forward to the complexity of the code needed especially if I want to purge the 'queue' often).

I've sketched my own pretty simple queued_mail table, which is going to incorporate some mailgun webhook data on it too to show delivery. I couldn't do that with the laravel jobs table of course, which is more general than simply for 'mail' jobs. I plan to build a focussed queue representation, just for mail.

But with all this, I did php artisan queue:table and am wondering how the jobs table does its stuff. I see it has a payload field. In my own case I could just store the 'name' of the mail I want sent. But what is in payload when the laravel queue is live and running? Is it something large and serialised? Am I right in saying it's not just some flag or other to say which mail (mailable?) needs sending?

I couldn't find this explained in the docs, but there's no real reason it should be, and it would be easy for someone to find by querying the jobs table if they are already running a live queue. Thanks for any info & discussion on this idea!

0 likes
2 replies
martinbean's avatar

@miwal You could set your queue driver to database, dispatched a job, and look yourself…?

In answer to the question, yes, it’s a serialised blob of the class being queued and its properties.

1 like
miwal's avatar
Level 11

Thanks martin. I don't currently have any client code that uses laravel queues at all, so it would take more work than that. Thanks for your answer. I was also curious in case anyone wanted to discuss the design questions I raised above, which is the other reason thought it worth making this post.

Please or to participate in this conversation.