Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 64394 invoked from network); 10 Dec 2010 21:13:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Dec 2010 21:13:27 -0000 Received: (qmail 11363 invoked by uid 500); 10 Dec 2010 21:13:27 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 11341 invoked by uid 500); 10 Dec 2010 21:13:27 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 11334 invoked by uid 99); 10 Dec 2010 21:13:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Dec 2010 21:13:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Dec 2010 21:13:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 663B623888CF; Fri, 10 Dec 2010 21:13:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1044514 - in /activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby: catstomp.rb listener.rb publisher.rb stompcat.rb Date: Fri, 10 Dec 2010 21:13:06 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101210211306.663B623888CF@eris.apache.org> Author: chirino Date: Fri Dec 10 21:13:05 2010 New Revision: 1044514 URL: http://svn.apache.org/viewvc?rev=1044514&view=rev Log: Simplifying the out of the box stomp ruby examples and defaulting the user id/password. Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/catstomp.rb activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/listener.rb activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/publisher.rb activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/stompcat.rb Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/catstomp.rb URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/catstomp.rb?rev=1044514&r1=1044513&r2=1044514&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/catstomp.rb (original) +++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/catstomp.rb Fri Dec 10 21:13:05 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -15,34 +15,28 @@ # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------ - require 'rubygems' require 'stomp' +user = ENV["STOMP_USER"] || "admin" +password = ENV["STOMP_PASSWORD"] || "password" +host = ENV["STOMP_HOST"] || "localhost" +port = ENV["STOMP_PORT"] || 61613 +destination = $*[0] || "/topic/event" + begin - @port = 61613 - @host = "localhost" - @user = ENV["STOMP_USER"]; - @password = ENV["STOMP_PASSWORD"] - - @host = ENV["STOMP_HOST"] if ENV["STOMP_HOST"] != NIL - @port = ENV["STOMP_PORT"] if ENV["STOMP_PORT"] != NIL - - @destination = "/topic/stompcat" - @destination = $*[0] if $*[0] != NIL - - $stderr.print "Connecting to stomp://#{@host}:#{@port} as #{@user}\n" - @conn = Stomp::Connection.open @user, @password, @host, @port, true - $stderr.print "Sending input to #{@destination}\n" - - @headers = {'persistent'=>'false'} - @headers['reply-to'] = $*[1] if $*[1] != NIL - - STDIN.each_line { |line| - @conn.send @destination, line, @headers - } - @conn.disconnect + $stderr.print "Connecting to stomp://#{host}:#{port} as #{user}\n" + conn = Stomp::Connection.open user, password, host, port, true + $stderr.print "Sending input to #{destination}\n" + + headers = {'persistent'=>'false'} + headers['reply-to'] = $*[1] if $*[1] != NIL + + STDIN.each_line { |line| + conn.publish destination, line, headers + } + conn.disconnect rescue end Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/listener.rb URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/listener.rb?rev=1044514&r1=1044513&r2=1044514&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/listener.rb (original) +++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/listener.rb Fri Dec 10 21:13:05 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -19,33 +19,35 @@ require 'rubygems' require 'stomp' -@conn = Stomp::Connection.open '', '', 'localhost', 61613, false -@count = 0 +user = ENV["STOMP_USER"] || "admin" +password = ENV["STOMP_PASSWORD"] || "password" +host = ENV["STOMP_HOST"] || "localhost" +port = ENV["STOMP_PORT"] || 61613 +destination = $*[0] || "/topic/event" -@conn.subscribe '/topic/event', { :ack =>"auto" } +conn = Stomp::Connection.open user, password, host, port, false +count = 0 + +conn.subscribe destination, { :ack =>"auto" } +start = Time.now while true - @msg = @conn.receive - if @msg.command == "MESSAGE" - if @msg.body == "SHUTDOWN" + msg = conn.receive + if msg.command == "MESSAGE" + if msg.body == "SHUTDOWN" + diff = Time.now - start + $stdout.print "Received #{count} in #{diff} seconds\n"; exit 0 - elsif @msg.body == "REPORT" - @diff = Time.now - @start - @body = "Received #{@count} in #{@diff} seconds"; - @conn.send '/queue/response', @body, {'persistent'=>'false'} - @count = 0; else - if @count == 0 - @start = Time.now - end - - @count += 1; - if @count % 1000 == 0 - $stdout.print "Received #{@count} messages.\n" + start = Time.now if count==0 + count += 1; + if count % 1000 == 0 + $stdout.print "Received #{count} messages.\n" end end else - $stdout.print "#{@msg.command}: #{@msg.body}\n" + $stdout.print "#{msg.command}: #{msg.body}\n" end end -@conn.disconnect \ No newline at end of file + +conn.disconnect Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/publisher.rb URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/publisher.rb?rev=1044514&r1=1044513&r2=1044514&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/publisher.rb (original) +++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/publisher.rb Fri Dec 10 21:13:05 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -19,49 +19,27 @@ require 'rubygems' require 'stomp' -@conn = Stomp::Connection.open '', '', 'localhost', 61613, false -@messages = 10000 -@batches = 40 -@subscribers = 10 -@size = 256 - -@DATA = "abcdefghijklmnopqrstuvwxyz"; -@body = ""; -for i in 0..(@size-1) - @body += @DATA[ i % @DATA.length,1] -end - -@times = [] -@conn.subscribe '/queue/response', { :ack =>"auto" } +messages = 10000 +size = 256 -for i in 1..(@batches) - @body += @DATA[ i % @DATA.length,1] - sleep 1 if i == 1 - - @start = Time.now - - for j in 1..@messages - @conn.publish '/topic/event', @body, {'persistent'=>'false'} - $stdout.print "Sent #{j} messages\n" if j%1000==0 - end - @conn.publish '/topic/event', "REPORT", {'persistent'=>'false'} - - @remaining = @subscribers - while @remaining > 0 - @msg = @conn.receive - if @msg.command == "MESSAGE" - @remaining -= 1 - $stdout.print "Received report: #{@msg.body}, remaining: #{@remaining}\n" - else - $stdout.print "#{@msg.command}: #{@msg.body}\n" - end - end - @diff = Time.now-@start - - $stdout.print "Batch #{i} of #{@batches} completed in #{@diff} seconds.\n" - @times[i] = @diff +user = ENV["STOMP_USER"] || "admin" +password = ENV["STOMP_PASSWORD"] || "password" +host = ENV["STOMP_HOST"] || "localhost" +port = ENV["STOMP_PORT"] || 61613 +destination = $*[0] || "/topic/event" + +conn = Stomp::Connection.open user, password, host, port, false + +DATA = "abcdefghijklmnopqrstuvwxyz"; +body = ""; +for i in 0..(size-1) + body += DATA[ i % DATA.length,1] end -@conn.publish '/topic/event', "SHUTDOWN", {'persistent'=>'false'} +for i in 1..messages + conn.publish destination, body, {'persistent'=>'false'} + $stdout.print "Sent #{i} messages\n" if i%1000==0 +end -@conn.disconnect \ No newline at end of file +conn.publish destination, "SHUTDOWN", {'persistent'=>'false'} +conn.disconnect Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/stompcat.rb URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/stompcat.rb?rev=1044514&r1=1044513&r2=1044514&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/stompcat.rb (original) +++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/ruby/stompcat.rb Fri Dec 10 21:13:05 2010 @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -19,31 +19,26 @@ require 'rubygems' require 'stomp' +user = ENV["STOMP_USER"] || "admin" +password = ENV["STOMP_PASSWORD"] || "password" +host = ENV["STOMP_HOST"] || "localhost" +port = ENV["STOMP_PORT"] || 61613 +destination = $*[0] || "/topic/event" + begin - @port = 61613 - @host = "localhost" - @user = ENV["STOMP_USER"]; - @password = ENV["STOMP_PASSWORD"] - - @host = ENV["STOMP_HOST"] if ENV["STOMP_HOST"] != NIL - @port = ENV["STOMP_PORT"] if ENV["STOMP_PORT"] != NIL - - @destination = "/topic/stompcat" - @destination = $*[0] if $*[0] != NIL - - $stderr.print "Connecting to stomp://#{@host}:#{@port} as #{@user}\n" - @conn = Stomp::Connection.open @user, @password, @host, @port, true - $stderr.print "Getting output from #{@destination}\n" - - @conn.subscribe @destination, { :ack =>"client" } - while true - @msg = @conn.receive - $stdout.print @msg.body - $stdout.flush - @conn.ack @msg.headers["message-id"] - end - @conn.disconnect + $stderr.print "Connecting to stomp://#{host}:#{port} as #{user}\n" + conn = Stomp::Connection.open user, password, host, port, true + $stderr.print "Getting output from #{destination}\n" + + conn.subscribe destination, { :ack =>"client" } + while true + msg = conn.receive + $stdout.print msg.body + $stdout.flush + conn.ack msg.headers["message-id"] + end + conn.disconnect rescue end