我使用Laravel 9。我有一个拍卖系统。当一个用户出价时,我调度一个AuctionBidPlaced事件:
class AuctionBidPlaced implements ShouldBroadcast
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
use DateTrait;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(
public CommunityAuctionBid $bid,
public ?User $user = null,
) {
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|string[]|string
*/
public function broadcastOn(): Channel
{
return new PrivateChannel($this->bid->auction->receivesBroadcastNotificationsOn());
}
/**
* Get the data to broadcast.
*
* @return array<string, mixed>
*/
public function broadcastWith(): array
{
return [
... some data I return ...
];
}
}
我这样称呼这个事件:
AuctionBidPlaced::dispatch($bid, $previousLeadingBidUser);
dispatchNow()
和sync()
不存在。
在我当地的环境中,它会立即起火。在生产上,有大约10秒的延迟。
我的本地QUEUE_DRIVER
是sync,
,生产是sqs
,但我不想让它排队。如何更改代码以保证即时派单?
1条答案
按热度按时间1cklez4t1#
要调用事件,请遵循以下格式: