Example #1
0
 /**
  * Tests Stomp->connect(), send(), and subscribe() - out of order. the messages should be received in FIFO order.
  */
 public function testAsyncSub()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->assertTrue($this->Stomp->send('/queue/test', 'test 1'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test 2'));
     $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid'));
     $frame = $this->Stomp->readFrame();
     $this->assertEquals($frame->body, 'test 1', 'test 1 was not received!');
     $frame = $this->Stomp->readFrame();
     $this->assertEquals($frame->body, 'test 2', 'test 2 was not received!');
 }
Example #2
0
 public function testAbortTransaction()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->assertTrue($this->simpleStomp->begin('my-id'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test t-id', ['transaction' => 'my-id']));
     $this->assertTrue($this->simpleStomp->abort('my-id'));
     $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid'));
     $this->Stomp->getConnection()->setReadTimeout(0, 500000);
     $frame = $this->Stomp->readFrame();
     $this->assertFalse($frame);
 }
Example #3
0
 /**
  * Read next message.
  *
  * @return bool|false|\Stomp\Transport\Frame
  */
 public function read()
 {
     if (!$this->active || $this->reachedEnd) {
         return false;
     }
     if ($frame = $this->client->readFrame()) {
         if ($this->stopOnEnd && $frame['browser'] == 'end') {
             $this->reachedEnd = true;
             return false;
         }
     }
     return $frame;
 }
Example #4
0
 /**
  * Tests Stomp byte messages
  */
 public function testByteMessages()
 {
     if (!$this->stomp->isConnected()) {
         $this->stomp->connect();
     }
     $body = 'test';
     $mapMessage = new Bytes($body);
     $this->stomp->send('/queue/bytes', $mapMessage);
     $simpleStomp = new SimpleStomp($this->stomp);
     $simpleStomp->subscribe('/queue/bytes');
     $msg = $this->stomp->readFrame();
     $this->assertEquals($msg->body, $body);
     $this->stomp->disconnect();
 }
Example #5
0
 /**
  * Tests Stomp byte messages
  */
 public function testByteMessages()
 {
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect();
     }
     $body = 'test';
     $mapMessage = new Bytes($body);
     $this->Stomp->send($this->queue, $mapMessage);
     $this->Stomp->disconnect(true);
     $this->simpleStomp->subscribe($this->queue, 'mysubid');
     $msg = $this->Stomp->readFrame();
     $this->assertEquals($msg->body, $body);
     $this->simpleStomp->ack($msg);
     $this->Stomp->disconnect();
 }
Example #6
0
 /**
  * Read response frame from server
  *
  * @return Frame|false when no frame to read
  */
 public function read()
 {
     return $this->client->readFrame();
 }