public function testCommitTransaction() { $this->assertTrue($this->Stomp->connect()); $this->assertTrue($this->Stomp->begin('my-id')); $this->assertTrue($this->Stomp->send('/queue/test', 'test 1', array('transaction' => 'my-id'))); $this->assertTrue($this->Stomp->commit('my-id')); $this->assertTrue($this->Stomp->subscribe('/queue/test')); $frame = $this->Stomp->readFrame(); $this->assertEquals('test 1', $frame->body, 'test 1 not received!'); $this->Stomp->ack($frame); }
$con->begin('tx1'); for ($i = 1; $i < 3; $i++) { $con->send('/queue/transactions', $i, array('transaction' => 'tx1')); } // if we abort transaction, messages will not be sent $con->abort('tx1'); // now send some messages for real $con->begin('tx2'); echo "Sent messages {\n"; for ($i = 1; $i < 5; $i++) { echo "\t{$i}\n"; $con->send('/queue/transactions', $i, array('transaction' => 'tx2')); } echo "}\n"; // they will be available for consumers after commit $con->commit('tx2'); // try to receive some messages $con->begin('tx3'); $messages = array(); for ($i = 1; $i < 3; $i++) { $msg = $con->readFrame(); array_push($messages, $msg); $con->ack($msg, 'tx3'); } // of we abort transaction, we will "rollback" out acks $con->abort('tx3'); $con->begin('tx4'); // so we need to ack received messages again // before we can receive more (prefetch = 1) if (count($messages) != 0) { foreach ($messages as $msg) {