#!/usr/bin/env php listen($channel); printf("Listening on channel '%s'\n", $listener->getChannel()); Loop::delay(3000, Amp\wrap(function () use ($listener) { // Unlisten in 3 seconds. printf("Unlistening from channel '%s'\n", $listener->getChannel()); return $listener->unlisten(); })); Loop::delay(1000, Amp\wrap(function () use ($pool, $channel) { return $pool->notify($channel, "Data 1"); // Send first notification. })); Loop::delay(2000, Amp\wrap(function () use ($pool, $channel) { return $pool->notify($channel, "Data 2"); // Send second notification. })); while (yield $listener->advance()) { /** @var \Amp\Postgres\Notification $notification */ $notification = $listener->getCurrent(); printf( "Received notification from PID %d on channel '%s' with payload: %s\n", $notification->pid, $notification->channel, $notification->payload ); } });