I am using CodeIgniter framework with RabbitMQ for doing time consuming activities such as sending emails, generating PDFs.
Whenever I change a code in the PHP files, say library or controller, until I restart the Apache, the old code is being executed by the RabbitMQ. How to resolve this?
The function in Controller,
public function receive()
{
$this->db->reconnect();
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('generate_pdf', false, false, false, false);
echo "[*] Started listening to connections... To exit press CTRL+C\n";
$generate_pdf = function ($data)
{
$this->generatepdf->generate($data); // Generatepdf.php library -> generate() function
};
$channel->basic_qos(null, 1, null);
$channel->basic_consume('generate_pdf', '', false, true, false, false, $generate_pdf)
while ($channel->is_consuming())
{
$channel->wait();
}
}
Starting this in termimal,
php index.php Controllerfile.php receive
This works fine as expected. So when a job is pushed to the queue, the generate()
function in the library file Generatepdf.php
is called and the execution is done.
However, if I modify the generate()
function thru an editor or I re-upload the file with changes, the changes does not reflect until I restart the Apache server.
Function definition before changes:
public function generate()
{
echo "Hello the data is 250";
}
Output: Hello the data is 250
Function definition after the change:
public function generate()
{
echo "Hello the data is 251";
}
Output before restarting Apache: Hello the data is 250
Output after restarting Apache: Hello the data is 251
Why does this happen? How can I made the execution to refresh the changes in the file?
from How to reload code changes in CodeIgniter with RabbitMQ?
No comments:
Post a Comment