Answer the question
In order to leave comments, you need to log in
How to send a queue of letters by several threads?
I am sending out letters.
I made a queue in the form of a table in MySql. The table has fields: id and status.
Status can have the following values: 'awaits','sending','sended','error','delivered','opened','clicked'.
How to competently make mailing of letters from this queue so that it can work in several threads?
So far, I came up with the following solution:
Cron or something else, as often as possible, runs a PHP script that makes a request:
SELECT * FROM mail WHERE status='awaits' ORDER BY id LIMIT 10
then takes min and max id from the result and doesUPDATE mail SET status='sending' WHERE id >= 5 AND id <= 14
Answer the question
In order to leave comments, you need to log in
At first
SET @id := 0;
UPDATE `mail`
SET `status` = `sending`
WHERE (@id := `id`) AND `status` = 'awaits'
ORDER BY `id`
LIMIT 1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question