Skip to content

Commit

Permalink
Merge pull request #4 from daron0ne/fix_subscribe
Browse files Browse the repository at this point in the history
Поправил формирование идентификатора подписки
  • Loading branch information
Serganbus authored Feb 4, 2019
2 parents 3eba148 + ad53ebf commit f15c1ca
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/StompClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ public function nack($frame)

/**
* @param array $queues Массив очередей, к которым нужно подписаться
*
* @return void
*
* @throws Exception
*/
public function subscribe($queues)
{
Expand All @@ -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);
}
}
Expand All @@ -231,6 +237,8 @@ public function subscribe($queues)
* Отписываемся от всех очередей
*
* @return void
*
* @throws Exception
*/
public function unsubscribe()
{
Expand All @@ -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);
}
}
Expand All @@ -264,6 +275,8 @@ public function unsubscribe()
* В случае необходимости устанавливает коннект
*
* @return null|Stomp
*
* @throws StompClientException
*/
private function getStomp()
{
Expand All @@ -286,6 +299,8 @@ private function getStomp()
* Возвращает коннект первого доступного брокера.
*
* @return Stomp
*
* @throws StompClientException
*/
private function initStomp()
{
Expand All @@ -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)
{
Expand Down

0 comments on commit f15c1ca

Please sign in to comment.