#110780 Не работает консольная команда
This commit is contained in:
		@@ -27,22 +27,22 @@ class AmqpHelper
 | 
				
			|||||||
        if (!isset(self::$connection[$key]))
 | 
					        if (!isset(self::$connection[$key]))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $credentials = ['heartbeat' => $queue['heartbeat']] ;
 | 
					            $credentials = ['heartbeat' => $queue['heartbeat']] ;
 | 
				
			||||||
            self::$connection = new \AMQPConnection($credentials);
 | 
					            self::$connection[$key] = new \AMQPConnection($credentials);
 | 
				
			||||||
            self::$connection->setLogin(Yii::$app->params['amqp']['login']);
 | 
					            self::$connection[$key]->setLogin(Yii::$app->params['amqp']['login']);
 | 
				
			||||||
            self::$connection->setPassword(Yii::$app->params['amqp']["pass"]);
 | 
					            self::$connection[$key]->setPassword(Yii::$app->params['amqp']["pass"]);
 | 
				
			||||||
            self::$connection->setHost(Yii::$app->params['amqp']["serverName"]);
 | 
					            self::$connection[$key]->setHost(Yii::$app->params['amqp']["serverName"]);
 | 
				
			||||||
            self::$connection->setPort(Yii::$app->params['amqp']["port"]);
 | 
					            self::$connection[$key]->setPort(Yii::$app->params['amqp']["port"]);
 | 
				
			||||||
            self::$connection->setVhost(Yii::$app->params['amqp']["vhostName"]);
 | 
					            self::$connection[$key]->setVhost(Yii::$app->params['amqp']["vhostName"]);
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                self::$connection->connect();
 | 
					                self::$connection[$key]->connect();
 | 
				
			||||||
            } catch (\AMQPConnectionException $exception)
 | 
					            } catch (\AMQPConnectionException $exception)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                AmqpLoger::log('error', $exception->getCode() . ' ' . $exception->getMessage(), 'system');
 | 
					                AmqpLoger::log('error', $exception->getCode() . ' ' . $exception->getMessage(), 'system');
 | 
				
			||||||
                throw $exception;
 | 
					                throw $exception;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return self::$connection;
 | 
					        return self::$connection[$key];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getChannel($queue)
 | 
					    public function getChannel($queue)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,12 +27,16 @@ class AmqpController extends Controller
 | 
				
			|||||||
     * @return int Exit code
 | 
					     * @return int Exit code
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function actionCreateAllQueue()
 | 
					    public function actionCreateAllQueue()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        foreach(Yii::$app->params['amqp']['projects'] as $keyProject =>$project)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $amqp = new AmqpHelper;
 | 
					            $amqp = new AmqpHelper;
 | 
				
			||||||
        foreach(Yii::$app->params['amqp']['queue'] as $key =>$value)
 | 
					            $amqp->setProject($keyProject);
 | 
				
			||||||
 | 
					            foreach ($project["queues"] as $key =>$value)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                $amqp->getQueueObject($key);
 | 
					                $amqp->getQueueObject($key);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return ExitCode::OK;
 | 
					        return ExitCode::OK;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user