activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1049973 - in /activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl: ./ listener publisher readme.md
Date Thu, 16 Dec 2010 13:42:40 GMT
Author: chirino
Date: Thu Dec 16 13:42:40 2010
New Revision: 1049973

URL: http://svn.apache.org/viewvc?rev=1049973&view=rev
Log:
Added perl examples contributed by Lionel Cons in issue AMQ-3086

Added:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener 
 (with props)
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher
  (with props)
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/readme.md

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener?rev=1049973&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener Thu
Dec 16 13:42:40 2010
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+# ------------------------------------------------------------------------
+# 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.
+# ------------------------------------------------------------------------
+#
+# sample listener
+#
+
+use strict;
+use warnings;
+use Net::STOMP::Client;
+use Time::HiRes qw(time);
+
+our(%Option, $Conn, $Count, $Start, $Run);
+
+$Option{user} = $ENV{STOMP_USER} || "admin";
+$Option{password} = $ENV{STOMP_PASSWORD} || "password";
+$Option{host} = $ENV{STOMP_HOST} || "localhost";
+$Option{port} = $ENV{STOMP_PORT} || 61613;
+$Option{destination} = $ENV{STOMP_DESTINATION} || "/topic/event";
+
+sub callback ($$) {
+    my($self, $frame) = @_;
+
+    $Start = time() unless $Count++;
+    $Run = 0 if $frame->body() eq "SHUTDOWN";
+}
+
+$Conn = Net::STOMP::Client->new(
+    host => $Option{host},
+    port => $Option{port},
+);
+$Conn->connect(
+    login    => $Option{user},
+    passcode => $Option{password},
+);
+printf("connected to %s:%d\n", $Conn->peer()->addr(), $Conn->peer()->port());
+$Conn->message_callback(\&callback);
+$Conn->subscribe(
+    destination => $Option{destination},
+    id          => 0,
+    ack         => "auto",
+);
+printf("subscribed to %s\n", $Option{destination});
+$Count = 0;
+$Run = 1;
+$Conn->wait_for_frames() while $Run;
+printf("received %d messages in %.3f seconds\n", $Count, time()-$Start);
+$Conn->disconnect();

Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/listener
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher?rev=1049973&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher
Thu Dec 16 13:42:40 2010
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+# ------------------------------------------------------------------------
+# 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.
+# ------------------------------------------------------------------------
+#
+# sample publisher
+#
+
+use strict;
+use warnings;
+use Net::STOMP::Client;
+use Time::HiRes qw(time);
+
+our(%Option, $Conn, $Start);
+
+$Option{user} = $ENV{STOMP_USER} || "admin";
+$Option{password} = $ENV{STOMP_PASSWORD} || "password";
+$Option{host} = $ENV{STOMP_HOST} || "localhost";
+$Option{port} = $ENV{STOMP_PORT} || 61613;
+$Option{destination} = $ENV{STOMP_DESTINATION} || "/topic/event";
+$Option{count} = $ENV{STOMP_COUNT} || 10000;
+
+$Conn = Net::STOMP::Client->new(
+    host => $Option{host},
+    port => $Option{port},
+);
+$Conn->connect(
+    login    => $Option{user},
+    passcode => $Option{password},
+);
+printf("connected to %s:%d\n", $Conn->peer()->addr(), $Conn->peer()->port());
+$Start = time();
+foreach (1 .. $Option{count}) {
+    $Conn->send(
+	destination => $Option{destination},
+	persistent  => "false",
+	body        => "Hello world from Perl",
+    );
+}
+$Conn->send(
+    destination => $Option{destination},
+    persistent  => "false",
+    body        => "SHUTDOWN",
+);
+printf("sent %d messages in %.3f seconds\n", $Option{count}+1, time()-$Start);
+$Conn->disconnect();

Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/publisher
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/readme.md?rev=1049973&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/readme.md
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/perl/readme.md
Thu Dec 16 13:42:40 2010
@@ -0,0 +1,12 @@
+Prereqs
+=======
+
+Install the [Net:STOMP::Client](http://search.cpan.org/~lcons/Net-STOMP-Client-0.9.4/) 
+library.
+
+CPAN users can install it by running:
+
+    cpan Net:STOMP::Client
+
+
+



Mime
View raw message