Example #1
0
<?php

/**
 *
 * Copyright 2005-2006 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * 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.
 */
require_once 'Stomp.php';
$c = new StompConnection("localhost");
$result = $c->connect("hiram", "test");
print_r($result);
$c->subscribe("/queue/FOO");
$c->send("/queue/FOO", "Hello World!");
// Wait for the message to come in..
$result = $c->readFrame();
print_r($result);
$c->disconnect();
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(E_ALL);
// include a library
require_once "Stomp.php";
// make a connection
$con = new StompConnection("tcp://localhost:61613");
// connect
$con->connect();
$con->subscribe("/temp-queue/clientreply", array('ack' => 'auto'));
$start = time();
$i = 33;
//for ($i = 0;$i<100;$i++) {
print "Sending request:";
print $con->send("/queue/jsonrpc", '{"version": "1.1", "method": "add", "params": [' . $i . ', 2009], "id": ' . ($i + 100) . '}', array('reply-to' => '/temp-queue/clientreply')) . "\n";
//sleep(3);
$msg = $con->readFrame(true, 10);
if (is_object($msg)) {
    print "Reply:\n";
    print $msg->body . "\n";
} else {
    print "Time out or Error\n";
}
//}
/*print "Reply:\n";
for ($i = 0;$i<2;$i++) {
	$msg = $con->readFrame();
	print $msg->body."\n";
}*/
$stop = time();
echo "Run time: " . ($stop - $start) . "\n";
// disconnect