Esempio n. 1
0
 public function testAbortTransaction()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->assertTrue($this->Stomp->begin('my-id'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test t-id', array('transaction' => 'my-id')));
     $this->assertTrue($this->Stomp->abort('my-id'));
     $this->assertTrue($this->Stomp->subscribe('/queue/test'));
     $this->Stomp->getConnection()->setReadTimeout(array(1, 0));
     $frame = $this->Stomp->readFrame();
     $this->assertFalse($frame);
 }
Esempio n. 2
0
 /**
  * Tests Stomp->abort()
  */
 public function testAbort()
 {
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect();
     }
     $this->Stomp->begin("tx1");
     $this->assertTrue($this->Stomp->send($this->queue, 'testSend', array("transaction" => "tx1")));
     $this->Stomp->abort("tx1");
     $this->Stomp->subscribe($this->queue);
     $frame = $this->Stomp->readFrame();
     $this->assertFalse($frame);
     $this->Stomp->unsubscribe($this->queue);
     $this->Stomp->disconnect();
 }
Esempio n. 3
0
 /**
  * Tests Stomp->abort()
  */
 public function testAbort()
 {
     $this->Stomp->setReadTimeout(1);
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect($this->login, $this->password);
     }
     $this->Stomp->begin('tx1');
     $this->assertTrue($this->Stomp->send($this->queue, 'testSend', array('transaction' => 'tx1')));
     $this->Stomp->abort('tx1');
     $this->Stomp->subscribe($this->queue);
     $frame = $this->Stomp->readFrame();
     $this->assertFalse($frame);
     $this->Stomp->unsubscribe($this->queue);
     $this->Stomp->disconnect();
 }
Esempio n. 4
0
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// include a library
use Stomp\Stomp;
// make a connection
$con = new Stomp('tcp://localhost:61613');
// connect
$con->connect();
$con->setReadTimeout(1);
// subscribe to the queue
$con->subscribe('/queue/transactions', array('ack' => 'client', 'activemq.prefetchSize' => 1));
// try to send some messages
$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');