已更新: 我的Laravel 5.6项目正在使用Pusher广播事件。
当我将队列驱动程序设置为default=database
时,
该事件已插入查询中,但未触发broadcastOn
。为什么?谢谢。
这是来自DebugBar的查询:
insert into `jobs` (`queue`, `attempts`, `reserved_at`, `available_at`, `created_at`, `payload`) values ('your-queue-name', '0', '', '1535037855', '1535037855’,
'{\"displayName\":\"App\\Events\\MessageSent\",\"job\":\"Illuminate\\Queue\\CallQueuedHandler@call\",\"maxTries\":null,\"timeout\":null,\"timeoutAt\":null,\"data\”:
{\"commandName\":\"Illuminate\\Broadcasting\\BroadcastEvent\",\"command\":\"O:38:\\"Illuminate\\Broadcasting\\BroadcastEvent\\":7:{s:5:\\"event\\";O:22:\\"App\\Events\\MessageSent\\":4:
{s:14:\\"broadcastQueue\\";s:15:\\"your-queue-name\\";s:4:\\"user\\";O:45:\\"Illuminate\\Contracts\\Database\\ModelIdentifier\\":4:
{s:5:\\"class\\";s:8:\\"App\\User\\";s:2:\\"id\\";i:6;s:9:\\"relations\\";a:0:
{}s:10:\\"connection\\";s:5:\\"mysql\\";}s:7:\\"message\\";O:45:\\"Illuminate\\Contracts\\Database\\ModelIdentifier\\":4:
{s:5:\\"class\\";s:11:\\"App\\Message\\";s:2:\\"id\\";i:1;s:9:\\"relations\\";a:0:
{}s:10:\\"connection\\";s:5:\\"mysql\\";}s:6:\\"socket\\";N;}s:10:\\"connection\\";N;s:5:\\"queue\\";N;s:15:\\"chainConnection\\";N;s:10:\\"chainQueue\\";N;s:5:\\"delay\\";N;s:7:\\"chained\\";a:0:{}}\"}}')
这是设置:
//queue.php
'connections' => [
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
这是Laravel事件监听器的输出:
info
MessageSent {#852 ▼
+broadcastQueue: "your-queue-name"
+user: User {#731 ▶}
+message: Message {#758 ▶}
+socket: null
}