Beispiel #1
0
 public function testCommitTransaction()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->Stomp->setSync(true);
     $this->assertTrue($this->simpleStomp->begin('my-id'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test 1', ['transaction' => 'my-id']));
     $this->assertTrue($this->simpleStomp->commit('my-id'));
     $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid'));
     $frame = $this->Stomp->readFrame();
     $this->assertEquals('test 1', $frame->body, 'test 1 not received!');
     $this->simpleStomp->ack($frame);
 }
Beispiel #2
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();
 }
Beispiel #3
0
 protected function consume()
 {
     $consumer = ClientProvider::getClient();
     $consumer->setClientId('test');
     $consumer->connect();
     $consumer->getConnection()->setReadTimeout(5);
     $simpleStomp = new SimpleStomp($consumer);
     $simpleStomp->subscribe($this->topic, 'myId', 'client-individual', null, ['durable' => 'true', 'auto-delete' => 'false']);
     $frame = $simpleStomp->read();
     $this->assertEquals($frame->body, 'test message');
     if ($frame != null) {
         $simpleStomp->ack($frame);
     }
     $simpleStomp->unsubscribe($this->topic, 'myId', ['durable' => 'true', 'auto-delete' => 'false']);
     $consumer->disconnect();
 }