Изменена логика для работы с очередью задач, чтобы её можно было использовать в дальнейшем в кластере серверов

This commit is contained in:
ErickSkrauch
2016-07-17 18:25:24 +03:00
parent 9ea689a700
commit 6d3db89140
8 changed files with 56 additions and 20 deletions

View File

@@ -3,27 +3,38 @@ namespace console\controllers;
use common\components\Mojang\Api as MojangApi;
use common\components\Mojang\exceptions\NoContentException;
use common\components\RabbitMQ\Component as RabbitMQComponent;
use common\models\amqp\UsernameChanged;
use common\models\MojangUsername;
use console\controllers\base\AmqpController;
use Yii;
class AccountQueueController extends AmqpController {
public function getExchangeName() {
return 'account';
return 'events';
}
public function getQueueName() {
return 'account-operations';
return 'accounts-events';
}
public function getExchangeDeclareArgs() {
protected function getExchangeDeclareArgs() {
return array_replace(parent::getExchangeDeclareArgs(), [
1 => RabbitMQComponent::TYPE_TOPIC, // type -> topic
3 => true, // durable -> true
]);
}
protected function getQueueBindArgs($exchangeName, $queueName) {
return [$queueName, $exchangeName, 'accounts.#'];
}
public function getRoutesMap() {
return [
'accounts.username-changed' => 'routeUsernameChanged',
];
}
public function routeUsernameChanged(UsernameChanged $body) {
$mojangApi = new MojangApi();
try {