From ad53ebf2a3c3e6e87e79c7e2bc2f42f1e3b46a2f Mon Sep 17 00:00:00 2001 From: usr3024 Date: Fri, 1 Feb 2019 22:09:35 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D0=B0=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/StompClient.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/StompClient.php b/src/StompClient.php index 907086f..7e5da1e 100644 --- a/src/StompClient.php +++ b/src/StompClient.php @@ -196,7 +196,10 @@ public function nack($frame) /** * @param array $queues Массив очередей, к которым нужно подписаться + * * @return void + * + * @throws Exception */ public function subscribe($queues) { @@ -209,7 +212,10 @@ public function subscribe($queues) try { foreach ($this->queues as $queue) { $stomp = $this->getStomp(); - if (!$stomp->subscribe($queue, ['id' => $stomp->getSessionId()])) { + + $sessionId = $stomp->getSessionId() . '_' . $queue; + + if (!$stomp->subscribe($queue, ['id' => $sessionId])) { throw new Exception('Queue: ' . $queue); } } @@ -231,6 +237,8 @@ public function subscribe($queues) * Отписываемся от всех очередей * * @return void + * + * @throws Exception */ public function unsubscribe() { @@ -241,7 +249,10 @@ public function unsubscribe() try { foreach ($this->queues as $queue) { $stomp = $this->getStomp(); - if (!$stomp->unsubscribe($queue, ['id' => $stomp->getSessionId()])) { + + $sessionId = $stomp->getSessionId() . '_' . $queue; + + if (!$stomp->unsubscribe($queue, ['id' => $sessionId])) { throw new Exception('Queue: ' . $queue); } } @@ -264,6 +275,8 @@ public function unsubscribe() * В случае необходимости устанавливает коннект * * @return null|Stomp + * + * @throws StompClientException */ private function getStomp() { @@ -286,6 +299,8 @@ private function getStomp() * Возвращает коннект первого доступного брокера. * * @return Stomp + * + * @throws StompClientException */ private function initStomp() { @@ -312,10 +327,13 @@ private function initStomp() /** * Подключение к брокеру по ссылке. * - * @param string $url - * @param string $login - * @param string $pw + * @param string $url + * @param string $login + * @param string $pw + * * @return Stomp|null + * + * @throws Exception */ private function connect($url, $login, $pw) {