Custom email queue backed by database
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Custom email queue backed by database
Based on some business logic, I need to create an email queue backed by a database table. I've tried to follow what the AI chat gave me but I'm missing a key piece.
I created my database queue handler class in my extension: packages/mypackage/src/MQueue/Queue/DBQueue.php
namespace MQueue/Queue
In my config/shop.php, I have added the following:
I'm using the following to read/write to the queue:
My 2 questions:
I created my database queue handler class in my extension: packages/mypackage/src/MQueue/Queue/DBQueue.php
namespace MQueue/Queue
In my config/shop.php, I have added the following:
Code: Select all
'resource' => [
... all the other standard stuff above this entry
'queue' => [
'mq-team' => [
'standard' => [
'class' => \MQueue\Queue\DBQueueTeam::class,
],
],
]
Code: Select all
$queue = $context->queue('mq-team', 'team/coachassign');
$queue->get();
- How do I properly configure the queue to use database class noted above?
- What configuration do I need to add to enable the madmin_queue capabilities I see in: https://github.com/aimeos/aimeos-base/b ... andard.php
Re: Custom email queue backed by database
On question #2, it looks like I just needed to modify the config/queue.php by changing the 'default' to be database. I will configure the .env file instead of making that hardcoded change just to confirm.
Is that the correct approach?
Is that the correct approach?
Re: Custom email queue backed by database
Unfortunately, the AI in the chat often mixes up things it learned from other code bases but which isn't applicable in Aimeos :-/
Using DB based queues is really simple and all you need is explained here:
https://aimeos.org/docs/latest/infrastr ... age-queues
Add a message to a queue:
Get the messages in a job controller sending the emails:
The "mq-email" is the key to the configuration of the queue manager if your have several queue services like DB, RabbitMQ, etc. and if it doesn't exist, it falls back to "mq" configuration defined in your ./config/shop.php. The "order/email/payment" is the name of the actual queue which you use and it can be any string. We use the path of the job controller to know easily know where the queue belongs to.
Using DB based queues is really simple and all you need is explained here:
https://aimeos.org/docs/latest/infrastr ... age-queues
Add a message to a queue:
Code: Select all
$queue = $this->context()
->queue( 'mq-email', 'order/email/payment' )
->add( json_encode( ['email' => 'me@example.com'] ) );
Code: Select all
$queue = $this->context()->queue( 'mq-email', 'order/email/payment' );
while( $msg = $queue->get() )
{
$data = json_decode( $msg->getBody() );
// perform the task
$queue->del( $msg );
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Custom email queue backed by database
How do I configure my own database backed class for a specific queue type ex: my-team?
It seemed like I just needed to add a configuration line item, is there something else much more difficult?
Thanks!
It seemed like I just needed to add a configuration line item, is there something else much more difficult?
Thanks!
Re: Custom email queue backed by database
Use this config for your own queue class:
You can see how other queue adapters are implemented here: https://github.com/aimeos/ai-mqueue
Code: Select all
'mq' => [
'adapter' => 'DBQueueTeam',
// implementation specific configuration
// ...
],
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
