Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/MessageBus/Handling/Handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/MessageBus/Pgmq/PgmqTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
Loading