Skip to content
Draft
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
9 changes: 7 additions & 2 deletions src/MessageBus/Pgmq/PgmqTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function __construct(
public function createQueue(string $name): void
{
Pgmq\createExtension($this->postgres);
Pgmq\createQueue($this->postgres, $name);
$queue = Pgmq\createQueue($this->postgres, $name);

$queue->ensureNotifyInsert();

$this->postgres->query('create schema if not exists thesis_message_bus;');
$this->postgres->query(
Expand Down Expand Up @@ -189,7 +191,10 @@ public function startConsumer(string $queue, ConsumerHandler $handler): PgmqCons
$timeoutWatcher,
new ChannelWatcher(
$polls,
$this->postgres->listen($queue->enableNotifyInsert()),
// Not enableNotifyInsert(): recreating the trigger on every start took a table lock that waited for open
// producer transactions. ensureNotifyInsert() only reads the catalog when notifications are in place,
// and restores them when lost (the throttle table is UNLOGGED and is emptied by crash recovery).
$this->postgres->listen($queue->ensureNotifyInsert()),
$timeoutWatcher,
),
]);
Expand Down
Loading