/**
  * Send a message that is already a frame. Ensure what we get back
  * is what we sent in the frame.
  */
 function testFrameSend()
 {
     MessageQueue::add_interface("default", array("queues" => array("testmainqueue"), "implementation" => "SimpleDBMQ", "encoding" => "raw", "send" => array("onShutdown" => "none"), "delivery" => array("callback" => array("MessageQueueTest", "messageCallback"), "onerror" => array("requeue"))));
     $testData = "Nigel mouse";
     $this->assertTrue($this->getQueueSizeSimpleDB("testmainqueue") == 0, "Main queue is empty before we put anything in it");
     $frame = new MessageFrame($testData);
     MessageQueue::send("testmainqueue", $frame);
     $this->assertTrue($this->getQueueSizeSimpleDB("testmainqueue") == 1, "Main queue has an item after we add to it");
     // Get messages, and make sure we get it back.
     $msgs = MessageQueue::get_messages("testmainqueue");
     $this->assertTrue($msgs != null, "Got a set");
     $this->assertTrue($msgs->Count() == 1, "Got one message");
     $msg = $msgs->First();
     $this->assertTrue($msg instanceof MessageFrame, "Message is a frame");
     $this->assertTrue($msg->body == $testData);
 }
 /**
  * Flush any buffered messages on the specified queue. If the queue is not buffered, or the buffer is empty, it has
  * no effect.
  * @static
  * @param  $queue
  * @return void
  */
 static function flush($queue)
 {
     $conf = self::get_queue_config($queue);
     if (!$conf) {
         throw new Exception("Error flushing queue '{$queue}': no matching configured queue");
     }
     if (!isset($conf["send"]) || !is_array($sendOpts = $conf["send"])) {
         return;
     }
     if (!isset($sendOpts["buffer"])) {
         return;
     }
     // no buffer
     $buffer = $sendOpts["buffer"];
     // The buffer is a queue. Get all the messages from that queue, and then invoke send on our implementation class
     $messages = MessageQueue::get_messages($buffer);
     // Send these messages to the original queue, with no buffering.
     if ($messages) {
         foreach ($messages as $m) {
             MessageQueue::send($queue, $m, array(), false);
         }
     }
 }