/** * Receives the messages and pass them to sender */ public function handle() { $this->channel->basic_consume($this->listenQueue, '', false, true, false, false, function ($msg) { $this->climate->br(); $this->climate->info('Received: ' . $msg->body); $input = json_decode($msg->body, true); try { $output = $this->interestCalculator->caculateInterest($input); $output['token'] = $this->token; $output = json_encode($output); $this->climate->out('Sending back: ' . $output); $this->channel->basic_publish($this->amqpFactory->buildMessage($output), '', $this->broadcastQueue); } catch (Exception $e) { $this->climate->error('Unable to handle the message: ' . $e->getMessage()); return false; } return true; }); while (count($this->channel->callbacks)) { $this->channel->wait(); } $this->channel->close(); $this->connection->close(); }
/** * @dataProvider canThrowExceptionsDataProvider * @param $input * @param $exceptionMsg */ public function testCanThrowExceptions($input, $exceptionMsg) { $this->setExpectedException('InvalidArgumentException', $exceptionMsg); $this->calculator->caculateInterest($input); }