You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/12/16 00:07:32 UTC
svn commit: r1049735 - in
/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php:
./ listener.php publisher.php readme.md
Author: chirino
Date: Wed Dec 15 23:07:31 2010
New Revision: 1049735
URL: http://svn.apache.org/viewvc?rev=1049735&view=rev
Log:
Added php examples.
Added:
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php (with props)
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php (with props)
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/readme.md
Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php?rev=1049735&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php Wed Dec 15 23:07:31 2010
@@ -0,0 +1,72 @@
+<?php
+# ------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# ------------------------------------------------------------------------
+
+$user = getenv("STOMP_USER");
+if( !$user ) $user = "admin";
+
+$password = getenv("STOMP_PASSWORD");
+if( !$password ) $password = "password";
+
+$host = getenv("STOMP_HOST");
+if( !$host ) $host = "localhost";
+
+$port = getenv("STOMP_PORT");
+if( !$port ) $port = 61613;
+
+$destination = '/topic/event';
+
+
+function now() {
+ list($usec,$sec) = explode(' ', microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+try {
+ $url = 'tcp://'.$host.":".$port;
+ $stomp = new Stomp($url, $user, $password);
+ $stomp->subscribe($destination);
+
+ $start = now();
+ $count = 0;
+ while(true) {
+ $frame = $stomp->readFrame();
+ if( $frame ) {
+ if( $frame->command == "MESSAGE" ) {
+ if($frame->body == "SHUTDOWN") {
+ $diff = round((now()-$start),2);
+ echo("Received ".$count." in ".$diff." seconds\n");
+ break;
+ } else {
+ if( $count==0 ) {
+ $start = now();
+ }
+ if( $count%1000 == 0 ) {
+ echo "Received ".$count." messages\n";
+ }
+ $count++;
+ }
+ } else {
+ echo "Unexpected frame.\n";
+ var_dump($frame);
+ }
+ }
+ }
+
+} catch(StompException $e) {
+ echo $e->getMessage();
+}
Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/listener.php
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php?rev=1049735&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php Wed Dec 15 23:07:31 2010
@@ -0,0 +1,56 @@
+<?php
+# ------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# ------------------------------------------------------------------------
+
+$user = getenv("STOMP_USER");
+if( !$user ) $user = "admin";
+
+$password = getenv("STOMP_PASSWORD");
+if( !$password ) $password = "password";
+
+$host = getenv("STOMP_HOST");
+if( !$host ) $host = "localhost";
+
+$port = getenv("STOMP_PORT");
+if( !$port ) $port = 61613;
+
+$destination = '/topic/event';
+$messages = 10000;
+$size = 256;
+
+$DATA = "abcdefghijklmnopqrstuvwxyz";
+$body = "";
+for($i=0; $i< $size; $i++) {
+ $body .= $DATA[ $i % 26];
+}
+
+try {
+ $url = 'tcp://'.$host.":".$port;
+ $stomp = new Stomp($url, $user, $password);
+
+ for($i=0; $i< $messages; $i++) {
+ $stomp->send($destination, $body);
+ if( $i%1000 == 0 ) {
+ echo "Sent ".$i." messages\n";
+ }
+ }
+
+ $stomp->send($destination, "SHUTDOWN");
+
+} catch(StompException $e) {
+ echo $e->getMessage();
+}
Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/publisher.php
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/readme.md?rev=1049735&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/readme.md (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/php/readme.md Wed Dec 15 23:07:31 2010
@@ -0,0 +1,12 @@
+Prereqs
+=======
+
+Install the [PHP Stomp client](http://www.php.net/manual/en/book.stomp.php)
+library.
+
+Pear users can install it by running:
+
+ pear install pecl.php.net/stomp
+
+Then you should add "extension=stomp.so" to php.ini
+