diff --git a/app/Listeners/AddUserToDiscourseThreadForEvent.php b/app/Listeners/AddUserToDiscourseThreadForEvent.php index 1571d48b4..b0c184d93 100644 --- a/app/Listeners/AddUserToDiscourseThreadForEvent.php +++ b/app/Listeners/AddUserToDiscourseThreadForEvent.php @@ -8,9 +8,11 @@ use App\Services\DiscourseService; use App\User; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Contracts\Queue\InteractsWithQueue; class AddUserToDiscourseThreadForEvent implements ShouldQueue { private $discourseService; + public $tries = 1; public function __construct(DiscourseService $discourseService) { @@ -28,6 +30,14 @@ private function getHost($idevents) { } public function handle(UserConfirmedEvent $e) { + // This call can block for a long time - add our own timeout so that we can fail it rather than block + // the whole queue. + pcntl_signal(SIGALRM, function () { + $this->fail(); + }); + + pcntl_alarm(10); + if ($e->iduser) { $event = Party::find($e->idevents); $user = User::find($e->iduser); @@ -46,5 +56,7 @@ public function handle(UserConfirmedEvent $e) { } } } + + pcntl_alarm(0); } } \ No newline at end of file