Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pushdelayedrule.php
1<?php
2
4
10
12{
13 private const MODE_SECTION = 1;
14 private const MODE_CONNECTION = 2;
15
21 protected function getTargetQueue(Interfaces\Message $message): ?Queue\Queue
22 {
23 switch ($this->getMode($message))
24 {
25 case self::MODE_SECTION:
26 return (new Queue\QueueFactory())
27 ->getById(Queue\QueueRegistry::QUEUE_LIST['DelayedSyncSection']);
28 case self::MODE_CONNECTION:
29 return (new Queue\QueueFactory())
30 ->getById(Queue\QueueRegistry::QUEUE_LIST['DelayedSyncConnection']);
31 default:
32 return null;
33 }
34 }
35
41 protected function getMessageHash(Interfaces\Message $message): string
42 {
43 $body = $message->getBody();
44 switch ($this->getMode($message))
45 {
46 case self::MODE_SECTION:
47 return 'section:' . $body[Sync\Push\Dictionary::PUSH_TYPE['sectionConnection']] ?? '';
48 case self::MODE_CONNECTION:
49 return 'connection:' . $body[Sync\Push\Dictionary::PUSH_TYPE['connection']] ?? '';
50 default:
51 return '';
52 }
53 }
54
60 private function getMode(Interfaces\Message $message): ?int
61 {
62 $routingKey = $message->getHeader(Dictionary::HEADER_KEYS['routingKey']);
63 if ($routingKey === PushManager::QUEUE_ROUTE_KEY_SECTION)
64 {
65 return self::MODE_SECTION;
66 }
67 elseif ($routingKey === PushManager::QUEUE_ROUTE_KEY_CONNECTION)
68 {
69 return self::MODE_CONNECTION;
70 }
71
72 return null;
73 }
74}