Hello, I have a two questions about Rabbit MQ. The first one is an implementation of the product question, and the the original reason for joining this group. The second one is a general troubleshooting question and I thought I'd ask while I had the attention of some experts.
Question 1: What I am attempting to do is fill a queue with messages that accumulate over time. Every hour, I want to awaken the receiver via a cron job and clear out the queue, and shut the receiver back down. The reason is I do not want to be responsible for the service going down, and as a way to ensure the service keeps running. I haven't found a solution to this yet. How can I accomplish this?
Question 2: As I'm testing this morning, I send a batch of 45 messages to the queue with a script. The messages can be seen in the queue dashboard. I run a modified receive.php script from the tutorials which creates an object out of the message and saves it to a database. The messages are cleared out of the queue and the records are updated in the database. I exit the receive.php file, and run the create messages script again. I see activity in the queue but nothing is being queued. The row count in the database remains the same. What is going on?
receive.php
<?phprequire_once __DIR__ . '/vendor/autoload.php';use PhpAmqpLib\Connection\AMQPStreamConnection;include 'classes/activity_record.php';$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');$channel = $connection->channel();$channel->queue_declare('hello', false, false, false, false);echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";$callback = function($msg) {echo " [x] Received ", $msg->body, "\n";create_record_object($msg);};$channel->basic_consume('hello', '', false, true, false, false, $callback);while(count($channel->callbacks)) {$channel->wait();}$channel->close();$connection->close();function create_record_object($msg){$data = json_decode($msg->body);$activity_record = new ActivityRecord($data->uid, $data->nid, $data->gid,$data->rr, $data->type, $data->timespan,$data->timestamp);$activity_record->save();}
function AMQP_message_send($json_string) {$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');$channel = $connection->channel();$channel->queue_declare('hello', false, false, false, false);$msg = new AMQPMessage($json_string);$channel->basic_publish($msg, '', 'hello');echo "Message Sent.";$channel->close();$connection->close();}
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
while(count($channel->callbacks)) {$channel->wait();}
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.