Example #1
0
 /**
  * Tests Stomp->abort()
  */
 public function testAbort()
 {
     $this->Stomp->setReadTimeout(1);
     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();
 }
Example #2
0
 /**
  * Tests Stomp->begin()
  */
 public function testBegin()
 {
     // TODO Auto-generated StompTest->testBegin()
     $this->markTestIncomplete("begin test not implemented");
     $this->Stomp->begin();
 }
Example #3
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 FuseSource\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");