|
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace App\Service;
|
|
namespace App\Service;
|
|
|
|
|
|
-use App\Job\CancelOrderJob;
|
|
|
|
use App\Job\DemoJob;
|
|
use App\Job\DemoJob;
|
|
-use App\Job\DemoTwoJob;
|
|
|
|
-use App\Job\PushGeTuiJob;
|
|
|
|
-use App\Job\PushOrderJob;
|
|
|
|
|
|
+use App\Job\PlayerJob;
|
|
|
|
+use App\Job\QuestionJob;
|
|
|
|
+
|
|
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
|
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
|
use Hyperf\AsyncQueue\Driver\DriverInterface;
|
|
use Hyperf\AsyncQueue\Driver\DriverInterface;
|
|
|
|
|
|
@@ -34,47 +33,28 @@ class QueueService
|
|
// 所以这里也不推荐使用 `make` 方法来创建 `Job` 对象。
|
|
// 所以这里也不推荐使用 `make` 方法来创建 `Job` 对象。
|
|
return $this->driver->push(new DemoJob($params), $delay);
|
|
return $this->driver->push(new DemoJob($params), $delay);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 生产消息 02.
|
|
|
|
|
|
+ * 生产消息.
|
|
* @param mixed $params 数据
|
|
* @param mixed $params 数据
|
|
* @param int $delay 延时时间 单位秒
|
|
* @param int $delay 延时时间 单位秒
|
|
*/
|
|
*/
|
|
- public function demoTwoPush($params, int $delay = 0): bool
|
|
|
|
- {
|
|
|
|
- return $this->driver->push(new DemoTwoJob($params), $delay);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 加入提醒司机接单队列.
|
|
|
|
- * @param array $params
|
|
|
|
- * @param int $delay 延时时间 单位秒
|
|
|
|
- * @return bool
|
|
|
|
- */
|
|
|
|
- public function pushOrder(array $params, int $delay = 0): bool
|
|
|
|
- {
|
|
|
|
- return $this->driver->push(new PushOrderJob($params), $delay);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 加入个推消息队列.
|
|
|
|
- * @param array $params
|
|
|
|
- * @param int $delay 延时时间 单位秒
|
|
|
|
- * @return bool
|
|
|
|
- */
|
|
|
|
- public function pushGeTui(array $params, int $delay = 0): bool
|
|
|
|
|
|
+ public function playerPush($params, int $delay = 0): bool
|
|
{
|
|
{
|
|
- return $this->driver->push(new PushGeTuiJob($params), $delay);
|
|
|
|
|
|
+ // 这里的 `DemoJob` 会被序列化存到 Redis 中,所以内部变量最好只传入普通数据
|
|
|
|
+ // 同理,如果内部使用了注解 @Value 会把对应对象一起序列化,导致消息体变大。
|
|
|
|
+ // 所以这里也不推荐使用 `make` 方法来创建 `Job` 对象。
|
|
|
|
+ return $this->driver->push(new PlayerJob($params), $delay);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 加入订单超时取消消息队列.
|
|
|
|
- * @param array $params
|
|
|
|
|
|
+ * 生产消息.
|
|
|
|
+ * @param mixed $params 数据
|
|
* @param int $delay 延时时间 单位秒
|
|
* @param int $delay 延时时间 单位秒
|
|
- * @return bool
|
|
|
|
*/
|
|
*/
|
|
- public function cancelOrder(array $params, int $delay = 0): bool
|
|
|
|
|
|
+ public function questionPush($params, int $delay = 0): bool
|
|
{
|
|
{
|
|
- return $this->driver->push(new CancelOrderJob($params), $delay);
|
|
|
|
|
|
+ // 这里的 `DemoJob` 会被序列化存到 Redis 中,所以内部变量最好只传入普通数据
|
|
|
|
+ // 同理,如果内部使用了注解 @Value 会把对应对象一起序列化,导致消息体变大。
|
|
|
|
+ // 所以这里也不推荐使用 `make` 方法来创建 `Job` 对象。
|
|
|
|
+ return $this->driver->push(new QuestionJob($params), $delay);
|
|
}
|
|
}
|
|
}
|
|
}
|