SHARE
TWEET

Untitled

a guest Jun 27th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function processQueue()
  2. {
  3.     // Make connection
  4.     $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
  5.     // Make channel
  6.     $channel = $connection->channel();
  7.     // Declare queue
  8.     $channel->queue_declare(QUEUE_NAME, false, false, false, false);
  9.  
  10.     // PHP callable
  11.     $callback = function ($msg) {
  12.  
  13.         //DO MESSAGE PROCESSING HERE
  14.  
  15.         $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
  16.  
  17.     };
  18.  
  19.     $channel->basic_consume(AGENTS_QUEUE_PROCESSING, '', false, true, false, false, $callback);
  20.  
  21.     // While queue is empty, wait
  22.     while (count($channel->callbacks)) {
  23.         // Wait
  24.         $channel->wait();
  25.     }
  26.  
  27.     // Close channel and connection
  28.     $channel->close();
  29.     $connection->close();
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top