-
Notifications
You must be signed in to change notification settings - Fork 0
/
queueexample.php
74 lines (67 loc) · 2.47 KB
/
queueexample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
use Joomla\CMS\Plugin\CMSPlugin;
use Weble\JoomlaQueues\Handler\ErrorHandler;
use Weble\JoomlaQueues\Handler\PingHandler;
use Weble\JoomlaQueues\Handler\SendEmailHandler;
use Weble\JoomlaQueues\Message\ErrorMessage;
use Weble\JoomlaQueues\Message\PingMessage;
use Weble\JoomlaQueues\Message\SendEmailMessage;
defined('_JEXEC') or die;
require_once(JPATH_LIBRARIES . '/joomla-queues/vendor/autoload.php');
class PlgQueueQueueExample extends CMSPlugin
{
protected $app;
protected $autoloadLanguage = true;
/**
* Get the available messages, and optionally route them to their handlers / transports
*/
public function onGetQueueMessages()
{
$transports = $this->params->get('ping_message_transports', null);
return [
// This goes to the default transport configured in the admin parameters
SendEmailMessage::class => [
SendEmailHandler::class
],
// This should fail and get logged to the failed queue
ErrorMessage::class => [
ErrorHandler::class
],
// This goes to the specified transports
// you can get the transports through the container:
// $container->transport->getTransportsKeys(); ['database']
PingMessage::class => [
[
'handler' => PingHandler::class,
'transports' => $transports
// 'method' => 'otherMethod'
]
]
];
}
/**
* Get the avaiable Queue Handlers, optionally specifying other options
* Implementing this event is not require, if you already routed the messages
* to their handler using the onGetQueueMessages.
*
* Also, the Handler can configure itself if it implements the MessageSubscriberInterface
*
* @see onGetQueueMessages method
*/
public function onGetQueueHandlers()
{
return [
SendEmailHandler::class => [
"handles" => [
SendEmailMessage::class
],
// "bus" => Container::getInstance('com_queues')->bus->getName(),
// "from_transport" => 'default' ,
// "method" => "someOtherHandlerClassMethodInsteadOfInvoke",
// "priority" => 0
],
// this one self implements through the MessageSubscriberInterface
PingHandler::class
];
}
}