1. Go to this page and download the library: Download v3knet/queue-module library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
v3knet / queue-module example snippets
use atsilex\module\Module;
use atsilex\module\system\events\AppEvent;
use Pimple\Container;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Bernard\Message\DefaultMessage;
class MyModule extends Module {
public function subscribe(Container $container, EventDispatcherInterface $dispatcher) {
$dispatcher->addListener('queue.queues.get', function (AppEvent $event) {
$queues = $event->getSubject();
$queues['my_module.demo_queue'] = DefaultMessage::class;
});
}
}
use atsilex\module\system\ModularAp;
use Bernard\Message\DefaultMessage;
$msg = new DefaultMessage('my_module.demo_queue, ['foo' => 'bar']);
$app['bernard.producer']->produce($msg);
use atsilex\module\Module;
use atsilex\module\system\events\AppEvent;
use Bernard\Router\SimpleRouter;
use Bernard\Message\DefaultMessage;
use Pimple\Container;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class MyModule extends Module {
public function subscribe(Container $container, EventDispatcherInterface $dispatcher) {
// …
$dispatcher->addListener('queue.router.create', function (AppEvent $event) {
$router = $event->getSubject();
$router->add('my_module.demo_queue', function (ImportMessage $m) use ($c) {
// Logic to process the message
});
});
}
}