Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Simple Queue Add-On With Workers Rate Topic   - - - - -

 
  • harmsmitsdev
  • Senior Member
  • Members
  • Join Date: 22-Feb 20
  • 237 posts

Posted 18 September 2021 - 12:05 PM #1

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/b...brands/bb_queue

 

Kind regards,


Best Brands Support - We empower your business!

info@bestbrands.eu


 
  • harmsmitsdev
  • Senior Member
  • Members
  • Join Date: 22-Feb 20
  • 237 posts

Posted 24 September 2021 - 09:23 PM #2

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.


Best Brands Support - We empower your business!

info@bestbrands.eu


 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2426 posts

Posted 25 September 2021 - 03:30 PM #3

Nice, thanks.


When life hands you lemons, bring on the Tequila baby!


 
  • harmsmitsdev
  • Senior Member
  • Members
  • Join Date: 22-Feb 20
  • 237 posts

Posted 08 March 2022 - 12:58 PM #4

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....lay-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/b...der.php#L34-L35

 

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


Best Brands Support - We empower your business!

info@bestbrands.eu