Simple Queue Add-On With Workers

Hey,

Seeing as a lot of people these days seem to be relying on cronjobs, I went ahead and wrote a worker implementation for CsCart. I have been using it the past few years and it works really well, especially for e.g. sending mail asynchronously, processing images, synchronizing product changes, etc.

Feel free to add functionality where needed.

https://github.com/best-brands/bb_queue

Kind regards,

I am currently reworking a part of this to be more robust (with failed job loggin). I am also checking whether there is a way for me to re-initialize the store context in some way, or whether I need to kill the worker after each job executed to reduce context leaking.

Nice, thanks.

Hello,

The worker add-on has been revised to log jobs to a table. There is also now a Laravel-like interface for creating the jobs (which should allow for an easier migration to Laravel if you intend on using them) with proper rescheduling support if the jobs has failed. The add-on will be released to the marketplace in the near future (awaiting cscart's approval and the release of v4.15)

Most notably, there is also now an example add-on for queueing mails through jobs. So for those who are looking for a free alternative to https://marketplace.cs-cart.com/cs-cart-sending-mail-with-delay-add-on.html might want to take a look.

Do mind that the new CsCart V4.15 version is required (to be released), which includes a few modifications that were needed, such as but not limited too:

1. Transaction interface with automatic rollback / commit. You can now use `db_transaction(Closure $f);` to start and commit a transaction. This was needed for row-level locking, to avoid concurrency issues (you can now have more than 1 worker reliably).

2. FQCN's now have priority over `is_callable`, meaning that you can now register everything from HookHandlers to other dependencies using the FQCN (https://github.com/best-brands/bb_queue/blob/0d075c2954b8ea8811ea59794bbf6d080c73917d/app/addons/bb_queue/src/ServiceProvider.php#L34-L35)

For 4.16 there might be Autowiring, although this is still to be discussed.