Published 5 months ago by lanatel
Hello guys. On my site, users will receive different types of emails. Some of them are related to registration on the site; others will be sent when the user asks questions, and so on. One type of emails is mass mailing. All of them will be queued with a different priority.
The queue worker will be running on a separate server (is it appropriate?), where the queues will be processed according to the priority. Bulk mailing will be in the same queue, but it should have some extra parameter that I can separate them later (for example, one day I have to send to all users a notification about the promotion on the site and these messages should be in one group, and after some time I will send messages on a completely different topic and they also should be separated). I need this to be able to delete all jobs that have not been executed yet and which handle sending emails from specific group or pause the job executions and continue it after a certain time.
So the main question if it is possible to implement. I have read about Laravel Horizon (I use Redis) and know about the tag existence. Can I use them to achieve my goal or they are used only for monitoring jobs?
I will be glad to hear any thoughts, ideas and advices. Thank you
Ok putting queues on a separate server is possible, although unless you have an obscene amount of jobs not really practical or necessary. You can have a queue for mass emails, for user notifications, for promotions and what not. This way you can just leave them running as they won't interfere with the rest of the processing. Just as a little experiment, try to fill a queue to the point it starts dropping records... You'll quickly notice it's nearly impossible for a normal applications (unless you have some bad code or something).
Theoretically yes, but why would you want to do that? If the queue begins with a 1000 jobs and finished 500 in 24 hours then you'll have only 500 jobs left in the queue. As soon as a job is done it's removed from the list of jobs. You just leave the queue open forever and it will process jobs until you kill the application. No need for any manual action.
@Borisu I understand. But I need it because site moderators will create templates for mass mailing and it is possible that sometimes they will do it bad (for example send it to wrong type of users or just type a bad text). So in this case I want to be able to stop execution jobs that responsible for this emails