TL;DR
Can't dispatch jobs in Laravel with milliseconds delay, since
available_at
column is in unix timestamp format and doesn't support milliseconds.
I use database driver for jobs and wanted to delay job dispatching. My algorithm requires me to dispatch jobs with milliseconds delay (say 100ms for example). In the documentation it is demonstrated with ->delay(now()->addMinutes(10));
. Also i noticed that job table's available at column is an integer column which is designated to be filled with unix timestamp.
When i dispatch my jobs with:
MyJob::dispatch($jobSpecs)->delay(now()->addMilliseconds(1000));
I can see that jobs differ in available_at
values. Difference is 1 as in seconds as expected. However when i try to dispatch with 100ms delay like so ->addMilliseconds(100)
i do not see any difference in available_at column value. I think it is an expected result since unix timestamp doesn't support milliseconds.
It is the number of seconds that have elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970
Therefore i am unable to dispatch with milliseconds delay. It actually dispatches just fine, but delay is not reflected to available_at
column.
How can i workaround it ?
Thank you