12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\main\service;
- use app\main\constants\MqConstants;
- class TransferService extends BaseService {
- const EXCHANGE_NAME ='cps.ex.topic';
- private $map = [];
- private static $route_key = null;
- /**
- * @var TransferService
- */
- protected static $self = null;
- /**
- * @return BaseService|TransferService
- */
- public static function instance()
- {
- if (self::$self == NULL) {
- self::$self = new self();
- }
- return self::$self;
- }
- //粉丝备份
- public function setBackups($id,$next = null){
- $this->map = [
- 'id' => $id,
- 'next' => $next
- ];
- self::$route_key = MqConstants::CHANNEL_FANS_BACKUPS;
- return $this;
- }
- //粉丝转移
- public function setTransfer($id,$next = null){
- $this->map = [
- 'id' => $id,
- 'next' => $next
- ];
- self::$route_key = MqConstants::CHANNEL_FANS_TRANSFER;
- return $this;
- }
- /**
- * 推送MQ消息
- */
- public function push(){
- $mq = MqService::instance()->getDotMqInstance();
- $mq->transferExchange($this->map, self::EXCHANGE_NAME, self::$route_key, 'topic');
- }
- }
|