activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r475302 - in /incubator/activemq/trunk/assembly/src/release/example/ruby: README.txt catstomp.rb stompcat.rb
Date Wed, 15 Nov 2006 16:36:19 GMT
Author: chirino
Date: Wed Nov 15 08:36:18 2006
New Revision: 475302

URL: http://svn.apache.org/viewvc?view=rev&rev=475302
Log:
Added some simple stompcat and catstomp scripts

Added:
    incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb   (with props)
    incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb   (with props)
Modified:
    incubator/activemq/trunk/assembly/src/release/example/ruby/README.txt

Modified: incubator/activemq/trunk/assembly/src/release/example/ruby/README.txt
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/assembly/src/release/example/ruby/README.txt?view=diff&rev=475302&r1=475301&r2=475302
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/example/ruby/README.txt (original)
+++ incubator/activemq/trunk/assembly/src/release/example/ruby/README.txt Wed Nov 15 08:36:18
2006
@@ -5,3 +5,23 @@
 - Install RubyGems see: http://docs.rubygems.org/
 - Install the stomp gem.  Run: gem install stomp
 
+Overview of stompcat.rb and catstomp.rb 
+==========================================
+
+The basic idea behind these scripts to to create something like netcat except over JMS destinations.
+
+catstomp - takes stdin and sends it to a stomp destination
+stompcat - outputs data received from a stomp destination
+
+A simple example usage:
+
+In console 1 run:
+cat | ./catstomp.rb
+
+In console 2 run:
+./stompcat.rb
+
+now any line you enter into console 1 will get sent to console 2.
+
+Hopefully these to scripts can get merged together in the future and the command line arguments
can change
+so that it look more like netcat.

Added: incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb?view=auto&rev=475302
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb (added)
+++ incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb Wed Nov 15 08:36:18
2006
@@ -0,0 +1,48 @@
+#!/usr/bin/ruby
+# ------------------------------------------------------------------------
+# 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.
+# ------------------------------------------------------------------------
+
+require 'rubygems'
+require 'stomp'
+
+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
+    }
+
+rescue 
+end
+

Propchange: incubator/activemq/trunk/assembly/src/release/example/ruby/catstomp.rb
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb?view=auto&rev=475302
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb (added)
+++ incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb Wed Nov 15 08:36:18
2006
@@ -0,0 +1,49 @@
+#!/usr/bin/ruby
+# ------------------------------------------------------------------------
+# 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.
+# ------------------------------------------------------------------------
+
+require 'rubygems'
+require 'stomp'
+
+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
+
+rescue 
+end
+

Propchange: incubator/activemq/trunk/assembly/src/release/example/ruby/stompcat.rb
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message