$this->channel->close(); $this->connection->close(); } public function run() { $this->channel->basic_consume($this->bank_config['queue_name'], '', false, true, false, false, array($this, 'on_response')); echo ' [*] Waiting for messages. To exit press CTRL+C', "\n"; $this->running = true; while (count($this->channel->callbacks) && $this->running) { $this->channel->wait(); } } public function stop() { $this->running = false; } function forward_to_aggregator($response, $correlation_id) { $connection = new AMQPStreamConnection('localhost', 5672, 'test', 'test'); $channel = $connection->channel(); $channel->queue_declare('aggregator', false, false, false, false); $msg = new AMQPMessage(json_encode($response), array('correlation_id' => $correlation_id)); $channel->basic_publish($msg, '', 'aggregator'); $channel->close(); $connection->close(); } } $bank_config = array('host' => 'datdb.cphbusiness.dk', 'port' => '5672', 'username' => 'student', 'password' => 'cph', 'queue_name' => 'vongrad_cphbusiness_json_1'); $normalizer = new Normalizer($bank_config); $normalizer->run();