diff --git a/src/MessageBus/Handling/Handlers.php b/src/MessageBus/Handling/Handlers.php index b55ba5f..9aacd48 100644 --- a/src/MessageBus/Handling/Handlers.php +++ b/src/MessageBus/Handling/Handlers.php @@ -54,7 +54,6 @@ public function with(string $messageClass, callable $handler, string $qualifier } $copy = clone $this; - /** @phpstan-ignore assign.propertyType */ $copy->handlers[$messageClass][$qualifier] = $handler; return $copy; diff --git a/src/MessageBus/Pgmq/PgmqTransport.php b/src/MessageBus/Pgmq/PgmqTransport.php index 66bdca6..d627fb4 100644 --- a/src/MessageBus/Pgmq/PgmqTransport.php +++ b/src/MessageBus/Pgmq/PgmqTransport.php @@ -196,7 +196,7 @@ public function startConsumer(string $queue, ConsumerHandler $handler): PgmqCons $iterator = $polls->iterate(); - EventLoop::queue(function () use ($queue, $handler, $completion, $watcher, $iterator): void { + EventLoop::queue(function () use ($queue, $handler, $completion, $watcher, $iterator, $polls): void { $watcher->watch(); try { @@ -238,6 +238,12 @@ public function startConsumer(string $queue, ConsumerHandler $handler): PgmqCons } finally { EventLoop::cancel($updateVisibilityId); } + + // A full batch means the queue may hold more messages. Inserts that already happened will not + // notify again, so waiting for the next signal would leave the backlog idle for up to $pollInterval. + if (\count($messages) === $this->batchSize && !$polls->isComplete()) { + $polls->pushAsync(null)->ignore(); + } } $completion->complete();