Skip to content

Commit

Permalink
Timeout waiting for new messages after 60s
Browse files Browse the repository at this point in the history
  • Loading branch information
Hipska committed Aug 9, 2024
1 parent bc25b4f commit 831c9b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/SnmpDiscoveryCollector.class.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Exception\AMQPTimeoutException;
use PhpAmqpLib\Message\AMQPMessage;

class SnmpDiscoveryCollector extends Collector
Expand Down Expand Up @@ -74,7 +75,12 @@ protected function Fetch(): array|false
while ($this->bDistributed && !empty($this->aIPAddresses))
{
// Wait until new message arrives
$this->oChannel->consume();
try {
$this->oChannel->wait(timeout: 60);
} catch (AMQPTimeoutException $e) {
$this->oChannel->queue_purge($this->sQueue);
throw $e;
}
$sBody = $this->oResponseMessage->getBody();
$iKey = $this->oResponseMessage->get('correlation_id');

Expand Down

0 comments on commit 831c9b6

Please sign in to comment.