public function testConnectionResetIfSocketExceptionIsThrown() { $pheanstalk = new Pheanstalk(self::SERVER_HOST, self::SERVER_PORT, self::CONNECT_TIMEOUT); Mock::generate('Pheanstalk_Connection'); $connection = new MockPheanstalk_Connection(''); $connection->returns('getHost', self::SERVER_HOST); $connection->returns('getPort', self::SERVER_PORT); $connection->returns('getConnectTimeout', self::CONNECT_TIMEOUT); $connection->throwOn('dispatchCommand', new Pheanstalk_Exception_SocketException('socket error simulated')); $pheanstalk->putInTube('testconnectionreset', __METHOD__); $pheanstalk->watchOnly('testconnectionreset'); $pheanstalk->setConnection($connection); $connection->expectOnce('dispatchCommand'); $job = $pheanstalk->reserve(); $this->assertEqual(__METHOD__, $job->getData()); }
<?php require_once 'php-airbrake-notifier/Services/Airbrake.php'; require_once 'pheanstalk/pheanstalk_init.php'; $airbrake = new Services_Airbrake(HOPTOAD_API_KEY); $k = array_rand($BEANSTALK_SERVERS); $pheanstalk = new Pheanstalk($BEANSTALK_SERVERS[$k]['host'], $BEANSTALK_SERVERS[$k]['port']); $pheanstalk->watch('airbrake')->ignore('default'); while ($job = $pheanstalk->reserve()) { $data = json_decode($job->getData()); echo date('Y-m-d H:i:s') . ' Processing Error: ' . $data->url . "\n"; $airbrake->curlRequest($data->url, $data->headers, $data->body); $pheanstalk->delete($job); }