Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
examplerule.php
1
<?php
2
3
namespace
Bitrix\Calendar\Core\Queue\Rule\Rules
;
4
5
use
Bitrix
;
6
use
Bitrix\Calendar\Core\Queue\Interfaces
;
7
use
Bitrix\Calendar\Core\Queue\Message\Dictionary
;
8
use
Bitrix\Calendar\Core\Queue\Queue\Queue
;
9
use
Bitrix\Calendar\Core\Queue\Queue\QueueFactory
;
10
use
Bitrix\Calendar\Core\Queue\Queue\QueueRegistry
;
11
use Bitrix\Calendar\Core\Queue\Rule\WakeUpAgentTrait;
12
13
class
ExampleRule
extends
DbRule
14
{
15
use WakeUpAgentTrait;
16
22
protected
function
getTargetQueue
(Interfaces\
Message
$message): ?
Queue
23
{
24
$routingKey = $message->getHeaders()[Dictionary::HEADER_KEYS[
'routingKey'
]] ??
null
;
25
if
($routingKey ===
'example.test'
)
26
{
27
$queue = (
new
QueueFactory
())->getById(QueueRegistry::QUEUE_LIST[
'EventDelayedSync'
]);
28
return
$queue;
29
}
30
31
return
null
;
32
}
33
39
protected
function
getMessageHash
(Interfaces\
Message
$message): string
40
{
41
return
'ExamplePrefix_'
. $message->getBody()[
'exampleField'
];
42
}
43
44
protected
function
handleRuleMasterFinish
(
Bitrix
\Main\
Event
$event):
Bitrix
\Main\
EventResult
45
{
46
$result = $this->wakeupAgent(
'Name of agent'
);
47
if
($result->isSuccess())
48
{
49
$result =
new
Bitrix\Main\EventResult
(
Bitrix
\Main\EventResult::SUCCESS, []);
50
}
51
else
52
{
53
$result =
new
Bitrix\Main\EventResult
(
Bitrix
\Main\EventResult::ERROR, []);
54
}
55
56
return
$result;
57
}
58
}
Bitrix\Calendar\Core\Queue\Message\Dictionary
Definition
dictionary.php:6
Bitrix\Calendar\Core\Queue\Queue\QueueFactory
Definition
queuefactory.php:6
Bitrix\Calendar\Core\Queue\Queue\QueueRegistry
Definition
queueregistry.php:7
Bitrix\Calendar\Core\Queue\Rule\Rules\DbRule
Definition
dbrule.php:12
Bitrix\Calendar\Core\Queue\Rule\Rules\ExampleRule
Definition
examplerule.php:14
Bitrix\Calendar\Core\Queue\Rule\Rules\ExampleRule\getMessageHash
getMessageHash(Interfaces\Message $message)
Definition
examplerule.php:39
Bitrix\Calendar\Core\Queue\Rule\Rules\ExampleRule\handleRuleMasterFinish
handleRuleMasterFinish(Bitrix\Main\Event $event)
Definition
examplerule.php:44
Bitrix\Calendar\Core\Queue\Rule\Rules\ExampleRule\getTargetQueue
getTargetQueue(Interfaces\Message $message)
Definition
examplerule.php:22
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Calendar\Core\Queue\Interfaces\Message
Definition
message.php:16
Bitrix\Calendar\Core\Queue\Interfaces\Queue
Definition
queue.php:5
Bitrix\Calendar\Core\Queue\Interfaces
Definition
consumer.php:3
Bitrix\Calendar\Core\Queue\Rule\Rules
Definition
dbrule.php:3
Bitrix
modules
calendar
lib
core
queue
rule
rules
examplerule.php
Создано системой
1.10.0