Example #1
0
 /**
  * Push an element onto the end of the queue
  *
  * @param  string     $message message to send to the queue
  * @param  \Zend\Queue\Queue $queue
  * @return \Zend\Queue\Message\Message
  */
 public function send($message, Queue\Queue $queue = null)
 {
     if ($queue === null) {
         $queue = $this->_queue;
     }
     $frame = $this->_client->createFrame();
     $frame->setCommand('SEND');
     $frame->setHeader('destination', $queue->getName());
     $frame->setHeader('content-length', strlen($message));
     $frame->setBody((string) $message);
     $this->_client->send($frame);
     $data = array('message_id' => null, 'body' => $message, 'md5' => md5($message), 'handle' => null);
     $options = array('queue' => $queue, 'data' => $data);
     $classname = $queue->getMessageClass();
     return new $classname($options);
 }
Example #2
0
 public function testSendAndReceive()
 {
     $frame = new \Zend\Queue\Stomp\Frame();
     $frame->setCommand('testing');
     $frame->setHeader('testing', 1);
     $frame->setBody('hello world');
     $client = new Client\Client();
     $client->addConnection('tcp', 'localhost', '11232', '\\ZendTest\\Queue\\Stomp\\Mock');
     $client->send($frame);
     $this->assertTrue($client->canRead());
     $test = $client->receive();
     $this->assertEquals('testing', $test->getCommand());
     $this->assertEquals(1, $test->getHeader('testing'));
     $this->assertEquals('hello world', $test->getBody());
 }