1212
1313class Queue extends \yii \queue \cli \Queue
1414{
15- // region Public Properties
1615 /**
1716 * use this property to filter job execution on a specific id
1817 * You can use this property when you need to run multiple environments with the same queue at the same time, multiple locals environments for example.
@@ -21,16 +20,16 @@ class Queue extends \yii\queue\cli\Queue
2120 */
2221 public ?string $ id = null ;
2322 public string $ queue = 'default ' ;
23+
2424 /** @var ServiceBus[] */
2525 public array $ queues = [
2626 'default ' => 'serviceBus ' ,
2727 ];
28- // endregion Public Properties
2928
30- // region Initialization
3129 /**
32- * @throws \yii\base\ InvalidConfigException
30+ * @throws InvalidConfigException
3331 */
32+ #[\Override]
3433 public function init (): void
3534 {
3635 parent ::init ();
@@ -41,9 +40,8 @@ public function init(): void
4140 $ this ->queues [$ queue ] = Instance::ensure ($ config , ServiceBus::class);
4241 }
4342 }
44- // endregion Initialization
4543
46- // region Public Methods
44+ #[\Override]
4745 public function push ($ job ): ?string
4846 {
4947 $ defaultQueue = $ this ->queue ;
@@ -67,11 +65,13 @@ public function push($job): ?string
6765 /**
6866 * Listens queue and runs each job.
6967 *
70- * @param bool $repeat whether to continue listening when queue is empty.
71- * @param int $timeout number of seconds to wait for next message.
68+ * @param bool $repeat whether to continue listening when queue is empty
69+ * @param int $timeout number of seconds to wait for next message
70+ *
71+ * @return null|int exit code
72+ *
73+ * @internal for worker command only
7274 *
73- * @return null|int exit code.
74- * @internal for worker command only.
7575 * @since 2.0.2
7676 */
7777 public function run (bool $ repeat , ?string $ queue = null , int $ timeout = 30 ): ?int
@@ -83,15 +83,12 @@ public function run(bool $repeat, ?string $queue = null, int $timeout = 30): ?in
8383 * @param string $id of a job message
8484 *
8585 * @throws NotSupportedException
86- * @return void status code
8786 */
8887 public function status ($ id ): void
8988 {
9089 throw new NotSupportedException ('Status is not supported in the driver. ' );
9190 }
92- // endregion Public Methods
9391
94- // region Protected Methods
9592 /**
9693 * @throws Exception
9794 * @throws InvalidConfigException
@@ -102,7 +99,7 @@ protected function processWorker(callable $canContinue, bool $repeat, string $qu
10299 while ($ canContinue ()) {
103100 $ message = $ this ->queues [$ queue ]->receiveMessage (ServiceBus::PEEK_LOCK , $ timeout );
104101
105- if ($ message !== null && $ message -> brokerProperties !== null ) {
102+ if (null !== $ message && null !== $ message -> brokerProperties ) {
106103 if ($ message ->brokerProperties ->to && !$ message ->brokerProperties ->isTo ($ this ->id )) {
107104 continue ;
108105 }
@@ -116,14 +113,15 @@ protected function processWorker(callable $canContinue, bool $repeat, string $qu
116113 }
117114
118115 /**
119- * @param $message
120- * @param int $ttr time to reserve in seconds
116+ * @param int $ttr time to reserve in seconds
121117 * @param int $delay
122118 * @param mixed $priority
119+ * @param mixed $message
123120 *
124- * @throws \JsonException
125- * @throws \yii\httpclient\Exception
126121 * @return string id of a job message
122+ *
123+ * @throws \JsonException
124+ * @throws Exception
127125 */
128126 protected function pushMessage ($ message , $ ttr , $ delay , $ priority ): string
129127 {
@@ -137,5 +135,4 @@ protected function pushMessage($message, $ttr, $delay, $priority): string
137135
138136 return $ azureMessage ->brokerProperties ->messageId ;
139137 }
140- // endregion Protected Methods
141138}
0 commit comments