Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
producerclientexample.php
1<?php
2
4
7use Bitrix\Calendar\Core\Queue;
8use CCalendar;
9
11{
20 public static function run()
21 {
22 // it's only for example
23 // in real cases rule should register in advance
24 self::registerRule();
25
26 $message = self::generateMessage();
27 self::sendMessage($message);
28 }
29
33 private static function generateMessage(): Message
34 {
35 return (new Message())
36 ->setBody([
37 'userId' => CCalendar::GetUserId(), // notice recipient
38 'content' => 'Message sended ' . date('Y-m-d H:i:s'), // notice text
39 'exampleField' => 'dwdwdw', // field for hash
40 ])
41 ->setRoutingKey('example')
42 ;
43 }
44
54 private static function sendMessage(Message $message)
55 {
56 Queue\Producer\Factory::getProduser()->send($message);
57 }
58
64 private static function registerRule()
65 {
66 Registry::getInstance()->registerRuleClass(RuleExample::class);
67 }
68}