Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorChristian Johansen <christian@gitorious.org>2011-05-30 17:34:41 (GMT)
committer Christian Johansen <christian@gitorious.org>2011-05-30 17:34:41 (GMT)
commit0e22d035d813a0a02d606872a9c7a004c86bef68 (patch)
treed7f86d9c91e11da52488aca6944a053cd42a6977 /vendor
parent1ede2ca8cf97c5f79949af7434b8f2d44e58e15c (diff)
Refactor the stomp poller so it works without Rails environment
- Put gems in groups corresponding to adapters in Gemfile - Load the correct group in the post-receive hook - Unvendor the activemessaging plugin, use the gem instead
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/activemessaging/Rakefile20
-rw-r--r--vendor/plugins/activemessaging/generators/a13g_test_harness/a13g_test_harness_generator.rb19
-rw-r--r--vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test.rhtml13
-rw-r--r--vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test_controller.rb29
-rw-r--r--vendor/plugins/activemessaging/generators/a13g_test_harness/templates/index.rhtml17
-rw-r--r--vendor/plugins/activemessaging/generators/filter/USAGE0
-rw-r--r--vendor/plugins/activemessaging/generators/filter/filter_generator.rb19
-rw-r--r--vendor/plugins/activemessaging/generators/filter/templates/filter.rb12
-rw-r--r--vendor/plugins/activemessaging/generators/filter/templates/filter_test.rb28
-rw-r--r--vendor/plugins/activemessaging/generators/processor/USAGE8
-rw-r--r--vendor/plugins/activemessaging/generators/processor/processor_generator.rb28
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/application.rb18
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/broker.yml71
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/jruby_poller117
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/messaging.rb12
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/poller21
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/processor.rb8
-rw-r--r--vendor/plugins/activemessaging/generators/processor/templates/processor_test.rb19
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/USAGE8
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/templates/controller.rb14
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/templates/helper.rb2
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/templates/index.rhtml4
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/templates/layout.rhtml16
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/templates/trace_processor.rb100
-rw-r--r--vendor/plugins/activemessaging/generators/tracer/tracer_generator.rb25
-rw-r--r--vendor/plugins/activemessaging/init.rb2
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging.rb126
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapter.rb21
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb411
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/base.rb82
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/jms.rb237
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/reliable_msg.rb190
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/stomp.rb107
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/test.rb159
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/adapters/wmq.rb202
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/filter.rb29
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/gateway.rb414
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb30
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/processor.rb45
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/support.rb31
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/test_helper.rb174
-rw-r--r--vendor/plugins/activemessaging/lib/activemessaging/trace_filter.rb34
-rw-r--r--vendor/plugins/activemessaging/messaging.rb.example5
-rw-r--r--vendor/plugins/activemessaging/poller.rb14
-rw-r--r--vendor/plugins/activemessaging/tasks/start_consumers.rake8
-rw-r--r--vendor/plugins/activemessaging/test/all_tests.rb10
-rw-r--r--vendor/plugins/activemessaging/test/asqs_test.rb101
-rw-r--r--vendor/plugins/activemessaging/test/config_test.rb42
-rw-r--r--vendor/plugins/activemessaging/test/filter_test.rb130
-rw-r--r--vendor/plugins/activemessaging/test/gateway_test.rb195
-rw-r--r--vendor/plugins/activemessaging/test/jms_test.rb61
-rw-r--r--vendor/plugins/activemessaging/test/reliable_msg_test.rb82
-rw-r--r--vendor/plugins/activemessaging/test/test_helper.rb16
-rw-r--r--vendor/plugins/activemessaging/test/tracer_test.rb68
54 files changed, 0 insertions, 3654 deletions
diff --git a/vendor/plugins/activemessaging/Rakefile b/vendor/plugins/activemessaging/Rakefile
deleted file mode 100644
index ae5de03..0000000
--- a/vendor/plugins/activemessaging/Rakefile
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rdoc/rdoc'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the ActiveMessaging plugin.'
-Rake::TestTask.new(:test) do |t|
-
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the ActiveMessaging plugin.'
-task :rdoc do
- rm_rf 'doc'
- RDoc::RDoc.new.document(%w(--line-numbers --inline-source --title ActiveMessaging README lib))
-end
diff --git a/vendor/plugins/activemessaging/generators/a13g_test_harness/a13g_test_harness_generator.rb b/vendor/plugins/activemessaging/generators/a13g_test_harness/a13g_test_harness_generator.rb
deleted file mode 100644
index dc7cc46..0000000
--- a/vendor/plugins/activemessaging/generators/a13g_test_harness/a13g_test_harness_generator.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class A13gTestHarnessGenerator < Rails::Generator::Base
- def manifest
- record do |m|
-
- controller_path = 'app/controllers'
- m.directory controller_path
- m.file 'active_messaging_test_controller.rb', File.join(controller_path, 'active_messaging_test_controller.rb')
-
- view_path = 'app/views/active_messaging_test'
- m.directory view_path
- m.file 'index.rhtml', File.join(view_path, 'index.rhtml')
-
- view_path = 'app/views/layouts'
- m.directory view_path
- m.file 'active_messaging_test.rhtml', File.join(view_path, 'active_messaging_test.rhtml')
-
- end
- end
-end
diff --git a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test.rhtml b/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test.rhtml
deleted file mode 100644
index 3701762..0000000
--- a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test.rhtml
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
-<head>
- <title>ActiveMessaging Test Harness: <%= controller.action_name %></title>
- <%= stylesheet_link_tag 'scaffold' %>
-</head>
-<body>
-
-<p style="color: green"><%= flash[:notice] %></p>
-
-<%= yield %>
-
-</body>
-</html>
diff --git a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test_controller.rb b/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test_controller.rb
deleted file mode 100644
index 06dd70d..0000000
--- a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/active_messaging_test_controller.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class ActiveMessagingTestController < ApplicationController
-
- include ActiveMessaging::MessageSender
-
- def index
- @destinations = ActiveMessaging::Gateway.named_destinations.values
-
- if request.post?
- @message = params[:message]
-
- if params[:destination].nil? || params[:destination].empty?
- flash[:notice] = "Please specify a destination."
- return
- else
- @destination = params[:destination].intern
- end
-
- if @message.nil? || @message.empty?
- flash[:notice] = "Please specify a message."
- return
- end
-
- puts "#{@destination} : #{@message}"
- publish @destination, @message
- flash[:notice] = "'#{@message}' sent to #{@destination}"
- end
- end
-
-end
diff --git a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/index.rhtml b/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/index.rhtml
deleted file mode 100644
index 64ed495..0000000
--- a/vendor/plugins/activemessaging/generators/a13g_test_harness/templates/index.rhtml
+++ /dev/null
@@ -1,17 +0,0 @@
-<h1>ActiveMessaging Test Harness</h1>
-
-<% form_tag :action => 'index' do |f| %>
-<p>
- <label for="destination">Destination:</label><br/>
- (broker: name => 'destination')<br/>
- <select name="destination">
- <option value=""></option>
- <%= options_from_collection_for_select @destinations, 'name', 'to_s', @destination %>
- </select>
-</p>
-<p>
- <label for="message">Message:</label><br/>
- <%= text_area_tag :message, @message, :size=>'50x10' %>
-</p>
-<%= submit_tag "submit" %>
-<% end -%>
diff --git a/vendor/plugins/activemessaging/generators/filter/USAGE b/vendor/plugins/activemessaging/generators/filter/USAGE
deleted file mode 100644
index e69de29..0000000
--- a/vendor/plugins/activemessaging/generators/filter/USAGE
+++ /dev/null
diff --git a/vendor/plugins/activemessaging/generators/filter/filter_generator.rb b/vendor/plugins/activemessaging/generators/filter/filter_generator.rb
deleted file mode 100644
index decc884..0000000
--- a/vendor/plugins/activemessaging/generators/filter/filter_generator.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class FilterGenerator < Rails::Generator::NamedBase
- def manifest
- record do |m|
- path = 'app/processors'
- test_path = 'test/functional'
-
- # Check for class naming collisions
- m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
-
- # filter and test directories
- m.directory File.join(path, class_path)
- m.directory File.join(test_path, class_path)
-
- # filter and test templates
- m.template 'filter.rb', File.join(path, class_path, "#{file_name}_filter.rb")
- m.template 'filter_test.rb', File.join(test_path, class_path, "#{file_name}_filter_test.rb")
- end
- end
-end
diff --git a/vendor/plugins/activemessaging/generators/filter/templates/filter.rb b/vendor/plugins/activemessaging/generators/filter/templates/filter.rb
deleted file mode 100644
index 2476462..0000000
--- a/vendor/plugins/activemessaging/generators/filter/templates/filter.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class <%= class_name %>Filter < ActiveMessaging::Filter
-
- attr_accessor :options
-
- def initialize(options={})
- @options = options
- end
-
- def process(message, routing)
- logger.debug "<%= class_name %>Filter filtering message: #{message.inspect} with routing: #{routing.inspect}"
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/filter/templates/filter_test.rb b/vendor/plugins/activemessaging/generators/filter/templates/filter_test.rb
deleted file mode 100644
index 42737ca..0000000
--- a/vendor/plugins/activemessaging/generators/filter/templates/filter_test.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require File.dirname(__FILE__) + '/../../vendor/plugins/activemessaging/lib/activemessaging/test_helper'
-
-class <%= class_name %>FilterTest < Test::Unit::TestCase
- include ActiveMessaging::TestHelper
-
- def setup
- # if you want to write code to tests against the filter directly
- load File.dirname(__FILE__) + "/../../app/processors/<%= file_name %>_filter.rb"
- @options = {:direction=>:incoming, :only=>:<%= file_name %>_test}
- @filter = <%= class_name %>Filter.new(@options)
- @destination = ActiveMessaging::Gateway.destination :<%= file_name %>_test, '/queue/<%= file_name %>.test.queue'
- end
-
- def teardown
- ActiveMessaging::Gateway.reset
- @filter = nil
- @destination = nil
- @options = nil
- end
-
- def test_<%= file_name %>_filter
- @message = ActiveMessaging::TestMessage.new(@destination.value, {'message-id'=>'test-message-id-header'}, 'message body')
- @routing = {:direction=>:incoming, :destination=>@destination}
- @filter.process(@message, @routing)
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/processor/USAGE b/vendor/plugins/activemessaging/generators/processor/USAGE
deleted file mode 100644
index 481cd05..0000000
--- a/vendor/plugins/activemessaging/generators/processor/USAGE
+++ /dev/null
@@ -1,8 +0,0 @@
-Description:
- Generates a stub ActiveMessaging Processor and associated test.
-
-Examples:
- ./script/generate processor HelloWorld
- will create:
- /app/processors/hello_world_processor.rb
- /test/functional/hello_world_processor_test.rb
diff --git a/vendor/plugins/activemessaging/generators/processor/processor_generator.rb b/vendor/plugins/activemessaging/generators/processor/processor_generator.rb
deleted file mode 100644
index 690ec86..0000000
--- a/vendor/plugins/activemessaging/generators/processor/processor_generator.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-class ProcessorGenerator < Rails::Generator::NamedBase
- def manifest
- record do |m|
- path = 'app/processors'
- test_path = 'test/functional'
-
- # Check for class naming collisions.
- m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
-
- # processor and test directories
- m.directory File.join(path, class_path)
- m.directory File.join(test_path, class_path)
-
- # processor and test templates
- m.template 'processor.rb', File.join(path, class_path, "#{file_name}_processor.rb")
- m.template 'processor_test.rb', File.join(test_path, class_path, "#{file_name}_processor_test.rb")
-
- m.template 'messaging.rb', File.join('config', "messaging.rb")
- m.file 'broker.yml', File.join('config', "broker.yml")
- m.file 'application.rb', File.join(path, "application.rb")
- if defined?(JRUBY_VERSION)
- m.file 'jruby_poller', File.join('script', "jruby_poller"), { :chmod => 0755 }
- else
- m.file 'poller', File.join('script', "poller"), { :chmod => 0755 }
- end
- end
- end
-end
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/application.rb b/vendor/plugins/activemessaging/generators/processor/templates/application.rb
deleted file mode 100644
index 2311215..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/application.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class ApplicationProcessor < ActiveMessaging::Processor
-
- # Default on_error implementation - logs standard errors but keeps processing. Other exceptions are raised.
- # Have on_error throw ActiveMessaging::AbortMessageException when you want a message to be aborted/rolled back,
- # meaning that it can and should be retried (idempotency matters here).
- # Retry logic varies by broker - see individual adapter code and docs for how it will be treated
- def on_error(err)
- if (err.kind_of?(StandardError))
- logger.error "ApplicationProcessor::on_error: #{err.class.name} rescued:\n" + \
- err.message + "\n" + \
- "\t" + err.backtrace.join("\n\t")
- else
- logger.error "ApplicationProcessor::on_error: #{err.class.name} raised: " + err.message
- raise err
- end
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/broker.yml b/vendor/plugins/activemessaging/generators/processor/templates/broker.yml
deleted file mode 100644
index b349d3b..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/broker.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# broker.yml
-#
-# Simple yaml file for the env specific configuration of the broker connections.
-# See the wiki for more information: http://code.google.com/p/activemessaging/wiki/Configuration
-#
-development:
- ############################
- # Stomp Adapter Properties #
- ############################
- adapter: stomp
-
- ## properties below are all defaults for this adapter
- # login: ""
- # passcode: ""
- # host: localhost
- # port: 61613
- # reliable: true
- # reconnectDelay: 5
-
- # NEW! enable stomp retry logic
- # will resend errored out messages to be retried when on_error throws ActiveMessaging::AbortMessageException
- #
- # Max number of times to retry an aborted message, for 0, will not retry (default)
- # retryMax: 0
- #
- # If error still occurs after retryMax, send message to specified dead letter queue
- # deadLetterQueue: '/queue/activemessaging/deadletter'
-
-
- ###################################
- # Websphere MQ Adapter Properties #
- ###################################
- # adapter: wmq
- # q_mgr_name: ""
- # poll_interval: .1
-
-
- #################################
- # Amazon SQS Adapter Properties #
- #################################
- # adapter: asqs
- # access_key_id: XXXXXXXXXXXXXXXXXXXX
- # secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-
- ## properties below are all defaults for this adapter
- # host: queue.amazonaws.com
- # port: 80
- # reliable: true
- # reconnectDelay: 5
- # aws_version: 2006-04-01
- # content_type: text/plain
- # poll_interval: 1
- # cache_queue_list: true
-
-
- ########################################
- # ReliableMessaging Adapter Properties #
- ########################################
- # adapter: reliable_msg
-
- ## properties below are all defaults for this adapter
- # poll_interval: 1
- # reliable: true
-
-test:
- adapter: test
- reliable: false
-
-production:
- adapter: stomp
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/jruby_poller b/vendor/plugins/activemessaging/generators/processor/templates/jruby_poller
deleted file mode 100644
index df91909..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/jruby_poller
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/sh
-
-JRUBY_CMD=`which jruby`
-RAILS_ROOT="$(dirname $0)/.."
-POLLER_RB="$RAILS_ROOT/vendor/plugins/activemessaging/poller.rb"
-OUT="$RAILS_ROOT/tmp/poller.output"
-PID_FILE="$RAILS_ROOT/tmp/poller0.pid"
-
-if [ -z "$JRUBY_CMD" ] ; then
- echo "Could not find jruby on your path."
- exit 1
-fi
-
-if [ ! -f $POLLER_RB ] ; then
- echo "Could not find the poller file at: $POLLER_RB"
- exit 1
-fi
-
-function start() {
- if [[ -s $PID_FILE && -n "$(ps -A | grep "^[ \t]*$(< $PID_FILE)")" ]] ; then
- PID=$(< $PID_FILE)
- echo "Poller already running with pid $PID."
- exit 1
- fi
- $JRUBY_CMD $POLLER_RB "$@" >> $OUT 2>&1 &
- PID=$!
- echo $PID > $PID_FILE
- echo "Poller started with pid=$PID"
-}
-
-function stop() {
- if [[ -z "$(ps -A | grep "^[ \t]*$(< $PID_FILE)")" ]] ; then
- echo "Poller is not currently running."
- exit 1
- fi
- if [ -z "$FORCE" ] ; then
- echo "Sending TERM signal to poller."
- kill -TERM $(< $PID_FILE)
- else
- echo "Sending KILL signal to poller."
- kill -KILL $(< $PID_FILE)
- fi
- rm $PID_FILE
-}
-
-function restart() {
- stop
- start
-}
-
-function run() {
- exec $JRUBY_CMD $POLLER_RB "$@"
-}
-
-function zap() {
- echo "Resetting to stopped state."
- [ -f $PID_FILE ] && rm $PID_FILE
-}
-
-function usage() {
- cat <<EOF
-Usage: poller <command> <options> -- <application options>
-
-* where <command> is one of:
- start start an instance of the application
- stop stop all instances of the application
- restart stop all instances and restart them afterwards
- run start the application and stay on top
- zap set the application to a stopped state
-
-* and where <options> may contain several of the following:
-
- -t, --ontop Stay on top (does not daemonize)
- -f, --force Force operation
-EOF
-
-}
-
-CMD=$1
-shift
-
-for i in "1" "2" ; do
- case "$1" in
- "-f"|"--force")
- FORCE="true"
- shift
- ;;
- "-t"|"--ontop")
- ONTOP="true"
- shift
- ;;
- esac
-done
-
-[ "$1" == "--" ] && shift
-
-case "$CMD" in
- "start")
- start
- ;;
- "stop")
- stop
- ;;
- "run")
- run
- ;;
- "restart")
- restart
- ;;
- "zap")
- zap
- ;;
- "usage"|*)
- usage
- exit 1
- ;;
-esac \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/messaging.rb b/vendor/plugins/activemessaging/generators/processor/templates/messaging.rb
deleted file mode 100644
index 8027e2e..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/messaging.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Add your destination definitions here
-# can also be used to configure filters, and processor groups
-#
-ActiveMessaging::Gateway.define do |s|
- #s.destination :orders, '/queue/Orders'
- #s.filter :some_filter, :only=>:orders
- #s.processor_group :group1, :order_processor
-
- s.destination :<%= singular_name %>, '/queue/<%= class_name %>'
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/poller b/vendor/plugins/activemessaging/generators/processor/templates/poller
deleted file mode 100644
index 4d13bbb..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/poller
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env ruby
-require 'rubygems'
-require 'daemons'
-
-APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
-script_file = File.join(File.expand_path(APP_ROOT),'vendor','plugins','activemessaging','poller.rb')
-tmp_dir = File.join(File.expand_path(APP_ROOT), 'tmp')
-
-options = {
- :app_name => "poller",
- :dir_mode => :normal,
- :dir => tmp_dir,
- :multiple => true,
- :ontop => false,
- :mode => :load,
- :backtrace => true,
- :monitor => true,
- :log_output => true
-}
-
-Daemons.run(script_file,options)
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/processor.rb b/vendor/plugins/activemessaging/generators/processor/templates/processor.rb
deleted file mode 100644
index 1a13563..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/processor.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class <%= class_name %>Processor < ApplicationProcessor
-
- subscribes_to :<%= singular_name %>
-
- def on_message(message)
- logger.debug "<%= class_name %>Processor received: " + message
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/processor/templates/processor_test.rb b/vendor/plugins/activemessaging/generators/processor/templates/processor_test.rb
deleted file mode 100644
index 67dc5f0..0000000
--- a/vendor/plugins/activemessaging/generators/processor/templates/processor_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require File.dirname(__FILE__) + '/../../vendor/plugins/activemessaging/lib/activemessaging/test_helper'
-require File.dirname(__FILE__) + '/../../app/processors/application'
-
-class <%= class_name %>ProcessorTest < Test::Unit::TestCase
- include ActiveMessaging::TestHelper
-
- def setup
- @processor = <%= class_name %>Processor.new
- end
-
- def teardown
- @processor = nil
- end
-
- def test_<%= file_name %>_processor
- @processor.on_message('Your test message here!')
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/tracer/USAGE b/vendor/plugins/activemessaging/generators/tracer/USAGE
deleted file mode 100644
index e4e1edc..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/USAGE
+++ /dev/null
@@ -1,8 +0,0 @@
-Description:
- Generates a stub ActiveMessaging Tracing Controller.
-
-Examples:
- ./script/generate tracer Tracer
- will create:
- /app/processors/tracer_processor.rb
- /app/views/tracer/index.rhtml
diff --git a/vendor/plugins/activemessaging/generators/tracer/templates/controller.rb b/vendor/plugins/activemessaging/generators/tracer/templates/controller.rb
deleted file mode 100644
index 462b251..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/templates/controller.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class <%= class_name %>Controller < ApplicationController
- include ActiveMessaging::MessageSender
-
- publishes_to :trace
-
- def index
- end
-
- def clear
- publish :trace, "<trace-control>clear</trace-control>"
- redirect_to :action=>'index'
- end
-
-end
diff --git a/vendor/plugins/activemessaging/generators/tracer/templates/helper.rb b/vendor/plugins/activemessaging/generators/tracer/templates/helper.rb
deleted file mode 100644
index 3fe2ecd..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/templates/helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module <%= class_name %>Helper
-end
diff --git a/vendor/plugins/activemessaging/generators/tracer/templates/index.rhtml b/vendor/plugins/activemessaging/generators/tracer/templates/index.rhtml
deleted file mode 100644
index c7a1205..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/templates/index.rhtml
+++ /dev/null
@@ -1,4 +0,0 @@
-<%=button_to 'Clear', :action=>'clear'%>
-
-<%=image_tag '../trace.png', :id => 'graph' %>
-
diff --git a/vendor/plugins/activemessaging/generators/tracer/templates/layout.rhtml b/vendor/plugins/activemessaging/generators/tracer/templates/layout.rhtml
deleted file mode 100644
index bee08a6..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/templates/layout.rhtml
+++ /dev/null
@@ -1,16 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title>Tracer</title>
- <%=javascript_include_tag :defaults %>
- </head>
- <body>
- <h2>Tracer</h2>
-
- <% if @flash[:note] -%>
- <div id="flash"><%= @flash[:note] %></div>
- <% end -%>
-
- <%= @content_for_layout %>
- </body>
-</html> \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/tracer/templates/trace_processor.rb b/vendor/plugins/activemessaging/generators/tracer/templates/trace_processor.rb
deleted file mode 100644
index cfb2d0e..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/templates/trace_processor.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-require 'mpath'
-require 'active_support'
-
-class Dot
-
- attr_accessor :name, :nodes, :edges, :clean_names
-
- def initialize name
- @name = name
- @nodes = {}
- @clean_names = {}
- @edges = []
- yield self
- end
-
- def node name, params = {}
- @nodes[clean_name(name)] = params.stringify_keys.reverse_merge "label"=>name
- end
-
- def clean_name name
- @clean_names[name] = "node#{@clean_names.length+1}" if @clean_names[name].nil?
- @clean_names[name]
- end
-
- def edge from, to
- edge = [clean_name(from), clean_name(to)]
- @edges << edge unless @edges.member? edge
- end
-
- def to_s
- dot = "digraph #{@name} {\n"
- @nodes.each do |node_name, options|
- dot += "\t#{node_name.to_s}"
- optionstrings = []
- options.keys.sort.each do |key|
- optionstrings << "#{key}=\"#{options[key]}\""
- end
- dot += " [#{optionstrings.join(', ')}]" if optionstrings.length>0
- dot += ";\n"
- end
- @edges.each {|e| dot += "\t#{e[0].to_s}->#{e[1].to_s};\n"}
- dot += "}\n"
- end
-
- def == other
- (other.name == name) && (other.nodes == nodes) && (other.edges == edges) && (other.clean_names == clean_names)
- end
-end
-
-class TraceProcessor < ActiveMessaging::Processor
- subscribes_to :trace
-
- @@dot = Dot.new("Trace") {}
-
- class << self
-
- end
-
- def dot
- @@dot
- end
-
- def on_message(message)
- xml = Mpath.parse(message)
- if (xml.sent?) then
- from = xml.sent.from.to_s
- queue = xml.sent.queue.to_s
-
- @@dot.node from
- @@dot.node queue, "shape" => 'box'
- @@dot.edge from, queue #hah - could do from => to
- elsif (xml.received?) then
- by = xml.received.by.to_s
- queue = xml.received.queue.to_s
-
- @@dot.node queue, "shape" => 'box'
- @@dot.node by
- @@dot.edge queue, by
- elsif (xml.trace_control) then
- command = xml.trace_control.to_s
- begin
- send command
- rescue
- puts "TraceProcessor: I don't understand the command #{command}"
- end
- end
- create_image
- end
-
- def create_image
- File.open(DOT_FILE, "w") {|f| f.puts @@dot.to_s }
- output_file = RAILS_ROOT + "/public/trace.png"
- `dot -Tpng -o #{output_file} #{DOT_FILE}`
- end
-
- def clear
- @@dot = Dot.new("Trace") {}
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/generators/tracer/tracer_generator.rb b/vendor/plugins/activemessaging/generators/tracer/tracer_generator.rb
deleted file mode 100644
index 3ed4ef8..0000000
--- a/vendor/plugins/activemessaging/generators/tracer/tracer_generator.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class TracerGenerator < Rails::Generator::NamedBase
- def manifest
- record do |m|
- path = 'app/controllers'
- m.directory path
- m.template 'controller.rb', File.join(path, "#{file_name}_controller.rb")
-
- path = 'app/processors'
- m.directory path
- m.template 'trace_processor.rb', File.join(path, "#{file_name}_processor.rb")
-
- path = 'app/helpers'
- m.directory path
- m.template 'helper.rb', File.join(path, "#{file_name}_helper.rb")
-
- path = 'app/views/layouts'
- m.directory path
- m.file 'layout.rhtml', File.join(path, "#{file_name}.rhtml")
-
- path = "app/views/#{file_name}"
- m.directory path
- m.file 'index.rhtml', File.join(path, "index.rhtml")
- end
- end
-end
diff --git a/vendor/plugins/activemessaging/init.rb b/vendor/plugins/activemessaging/init.rb
deleted file mode 100644
index 62f9404..0000000
--- a/vendor/plugins/activemessaging/init.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'ostruct'
-require 'activemessaging'
diff --git a/vendor/plugins/activemessaging/lib/activemessaging.rb b/vendor/plugins/activemessaging/lib/activemessaging.rb
deleted file mode 100644
index fc83b91..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-module ActiveMessaging
-
- VERSION = "0.5" #maybe this should be higher, but I'll let others judge :)
-
- # Used to indicate that the processing for a thread shoud complete
- class StopProcessingException < Interrupt #:nodoc:
- end
-
- # Used to indicate that the processing on a message should cease,
- # and the message should be returned back to the broker as best it can be
- class AbortMessageException < Exception #:nodoc:
- end
-
- # Used to indicate that the processing on a message should cease,
- # but no further action is required
- class StopFilterException < Exception #:nodoc:
- end
-
- def ActiveMessaging.logger
- @@logger = RAILS_DEFAULT_LOGGER if !defined?(@@logger) && (defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil?)
- @@logger = ActiveRecord::Base.logger unless defined?(@@logger)
- @@logger = Logger.new(STDOUT) unless defined?(@@logger)
- @@logger
- end
-
- # DEPRECATED, so I understand, but I'm using it nicely below.
- def self.load_extensions
- require 'logger'
- require 'activemessaging/support'
- require 'activemessaging/gateway'
- require 'activemessaging/adapter'
- require 'activemessaging/message_sender'
- require 'activemessaging/processor'
- require 'activemessaging/filter'
- require 'activemessaging/trace_filter'
-
- # load all under the adapters dir
- Dir[RAILS_ROOT + '/vendor/plugins/activemessaging/lib/activemessaging/adapters/*.rb'].each{|a|
- begin
- adapter_name = File.basename(a, ".rb")
- require 'activemessaging/adapters/' + adapter_name
- rescue RuntimeError, LoadError => e
- logger.debug "ActiveMessaging: adapter #{adapter_name} not loaded: #{ e.message }"
- end
- }
- end
-
- def self.load_config
- path = File.expand_path("#{RAILS_ROOT}/config/messaging.rb")
- begin
- load path
- rescue MissingSourceFile
- logger.debug "ActiveMessaging: no '#{path}' file to load"
- rescue
- raise $!, " ActiveMessaging: problems trying to load '#{path}': \n\t#{$!.message}"
- end
- end
-
- def self.load_processors(first=true)
- #Load the parent processor.rb, then all child processor classes
- load RAILS_ROOT + '/vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb' unless defined?(ActiveMessaging::MessageSender)
- load RAILS_ROOT + '/vendor/plugins/activemessaging/lib/activemessaging/processor.rb' unless defined?(ActiveMessaging::Processor)
- load RAILS_ROOT + '/vendor/plugins/activemessaging/lib/activemessaging/filter.rb' unless defined?(ActiveMessaging::Filter)
- logger.debug "ActiveMessaging: Loading #{RAILS_ROOT + '/app/processors/application.rb'}" if first
- load RAILS_ROOT + '/app/processors/application.rb' if File.exist?("#{RAILS_ROOT}/app/processors/application.rb")
- Dir[RAILS_ROOT + '/app/processors/*.rb'].each do |f|
- unless f.match(/\/application.rb/)
- logger.debug "ActiveMessaging: Loading #{f}" if first
- load f
- end
- end
- end
-
- def self.reload_activemessaging
- # this is resetting the messaging.rb
- ActiveMessaging::Gateway.filters = []
- ActiveMessaging::Gateway.named_destinations = {}
- ActiveMessaging::Gateway.processor_groups = {}
-
- # now load the config
- load_config
- load_processors(false)
- end
-
- def self.load_activemessaging
- load_extensions
- load_config
- load_processors
- end
-
- def self.start
- if ActiveMessaging::Gateway.subscriptions.empty?
- err_msg = <<EOM
-
-ActiveMessaging Error: No subscriptions.
-If you have no processor classes in app/processors, add them using the command:
- script/generate processor DoSomething"
-
-If you have processor classes, make sure they include in the class a call to 'subscribes_to':
- class DoSomethingProcessor < ActiveMessaging::Processor
- subscribes_to :do_something
-
-EOM
- puts err_msg
- logger.error err_msg
- exit
- end
-
- Gateway.start
- end
-
-end
-
-#load these once to start with
-ActiveMessaging.load_activemessaging
-
-
-# reload these on each request - leveraging Dispatcher semantics for consistency
-require 'dispatcher' unless defined?(::Dispatcher)
-
-# add processors and config to on_prepare if supported (rails 1.2+)
-if ::Dispatcher.respond_to? :to_prepare
- ::Dispatcher.to_prepare :activemessaging do
- ActiveMessaging.reload_activemessaging
- end
-end
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapter.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapter.rb
deleted file mode 100644
index e08d675..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapter.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module ActiveMessaging
-
- # include this module to make a new adapter - will register the adapter w/gateway so an be used in connection config
- module Adapter
-
- def self.included(included_by)
- class << included_by
- def register adapter_name
- Gateway.register_adapter adapter_name, self
- end
- end
- end
-
- def logger()
- @@logger = ActiveMessaging.logger unless defined?(@@logger)
- @@logger
- end
-
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb
deleted file mode 100644
index cde6bf5..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb
+++ /dev/null
@@ -1,411 +0,0 @@
-require 'rubygems'
-require 'net/http'
-require 'openssl'
-require 'base64'
-require 'cgi'
-require 'time'
-
-module ActiveMessaging
- module Adapters
- module AmazonSQS
-
- class Connection
- include ActiveMessaging::Adapter
-
- register :asqs
-
- QUEUE_NAME_LENGTH = 1..80
- # MESSAGE_SIZE = 1..(256 * 1024)
- MESSAGE_SIZE = 1..(8 * 1024)
- VISIBILITY_TIMEOUT = 0..(24 * 60 * 60)
- NUMBER_OF_MESSAGES = 1..255
- GET_QUEUE_ATTRIBUTES = ['All', 'ApproximateNumberOfMessages', 'VisibilityTimeout']
- SET_QUEUE_ATTRIBUTES = ['VisibilityTimeout']
-
- #configurable params
- attr_accessor :reliable, :reconnectDelay, :access_key_id, :secret_access_key, :aws_version, :content_type, :host, :port, :poll_interval, :cache_queue_list
-
- #generic init method needed by a13g
- def initialize cfg
- raise "Must specify a access_key_id" if (cfg[:access_key_id].nil? || cfg[:access_key_id].empty?)
- raise "Must specify a secret_access_key" if (cfg[:secret_access_key].nil? || cfg[:secret_access_key].empty?)
-
- @access_key_id=cfg[:access_key_id]
- @secret_access_key=cfg[:secret_access_key]
- @request_expires = cfg[:requestExpires] || 10
- @request_retry_count = cfg[:requestRetryCount] || 5
- @aws_version = cfg[:aws_version] || '2008-01-01'
- @content_type = cfg[:content_type] || 'text/plain'
- @host = cfg[:host] || 'queue.amazonaws.com'
- @port = cfg[:port] || 80
- @protocol = cfg[:protocol] || 'http'
- @poll_interval = cfg[:poll_interval] || 1
- @reconnect_delay = cfg[:reconnectDelay] || 5
- @aws_url="#{@protocol}://#{@host}"
-
- @cache_queue_list = cfg[:cache_queue_list].nil? ? true : cfg[:cache_queue_list]
- @reliable = cfg[:reliable].nil? ? true : cfg[:reliable]
-
- #initialize the subscriptions and queues
- @subscriptions = {}
- @current_subscription = 0
- queues
- end
-
- def disconnect
- #it's an http request - there is no disconnect - ha!
- end
-
- # queue_name string, headers hash
- # for sqs, make sure queue exists, if not create, then add to list of polled queues
- def subscribe queue_name, message_headers={}
- # look at the existing queues, create any that are missing
- queue = get_or_create_queue queue_name
- if @subscriptions.has_key? queue.name
- @subscriptions[queue.name].add
- else
- @subscriptions[queue.name] = Subscription.new(queue.name, message_headers)
- end
- end
-
- # queue_name string, headers hash
- # for sqs, attempt delete the queues, won't work if not empty, that's ok
- def unsubscribe queue_name, message_headers={}
- if @subscriptions[queue_name]
- @subscriptions[queue_name].remove
- @subscriptions.delete(queue_name) if @subscriptions[queue_name].count <= 0
- end
- end
-
- # queue_name string, body string, headers hash
- # send a single message to a queue
- def send queue_name, message_body, message_headers={}
- queue = get_or_create_queue queue_name
- send_messsage queue, message_body
- end
-
- # receive a single message from any of the subscribed queues
- # check each queue once, then sleep for poll_interval
- def receive
- raise "No subscriptions to receive messages from." if (@subscriptions.nil? || @subscriptions.empty?)
- start = @current_subscription
- while true
- # puts "calling receive..."
- @current_subscription = ((@current_subscription < @subscriptions.length-1) ? @current_subscription + 1 : 0)
- sleep poll_interval if (@current_subscription == start)
- queue_name = @subscriptions.keys.sort[@current_subscription]
- queue = queues[queue_name]
- subscription = @subscriptions[queue_name]
- unless queue.nil?
- messages = retrieve_messsages queue, 1, subscription.headers[:visibility_timeout]
- return messages[0] unless (messages.nil? or messages.empty? or messages[0].nil?)
- end
- end
- end
-
- def received message, headers={}
- begin
- delete_message message
- rescue Object=>exception
- logger.error "Exception in ActiveMessaging::Adapters::AmazonSQS::Connection.received() logged and ignored: "
- logger.error exception
- end
- end
-
- def unreceive message, headers={}
- # do nothing; by not deleting the message will eventually become visible again
- return true
- end
-
- protected
-
- def create_queue(name)
- validate_new_queue name
- response = make_request('CreateQueue', nil, {'QueueName'=>name})
- add_queue response.get_text("//QueueUrl") unless response.nil?
- end
-
- def delete_queue queue
- validate_queue queue
- response = make_request('DeleteQueue', "#{queue.queue_url}")
- end
-
- def list_queues(queue_name_prefix=nil)
- validate_queue_name queue_name_prefix unless queue_name_prefix.nil?
- params = queue_name_prefix.nil? ? {} : {"QueueNamePrefix"=>queue_name_prefix}
- response = make_request('ListQueues', nil, params)
- response.nil? ? [] : response.nodes("//QueueUrl").collect{ |n| add_queue(n.text) }
- end
-
- def get_queue_attributes(queue, attribute='All')
- validate_get_queue_attribute(attribute)
- params = {'AttributeName'=>attribute}
- response = make_request('GetQueueAttributes', "#{queue.queue_url}")
- attributes = {}
- response.each_node('/GetQueueAttributesResponse/GetQueueAttributesResult/Attribute') { |n|
- n = n.elements['Name'].text
- v = n.elements['Value'].text
- attributes[n] = v
- }
- if attribute != 'All'
- attributes[attribute]
- else
- attributes
- end
- end
-
- def set_queue_attribute(queue, attribute, value)
- validate_set_queue_attribute(attribute)
- params = {'Attribute.Name'=>attribute, 'Attribute.Value'=>value.to_s}
- response = make_request('SetQueueAttributes', "#{queue.queue_url}", params)
- end
-
- def delete_queue queue
- validate_queue queue
- response = make_request('DeleteQueue', "#{queue.queue_url}")
- end
-
- # in progress
- def send_messsage queue, message
- validate_queue queue
- validate_message message
- response = make_request('SendMessage', queue.queue_url, {'MessageBody'=>message})
- response.get_text("//MessageId") unless response.nil?
- end
-
- def retrieve_messsages queue, num_messages=1, timeout=nil
- validate_queue queue
- validate_number_of_messages num_messages
- validate_timeout timeout if timeout
-
- params = {'MaxNumberOfMessages'=>num_messages.to_s}
- params['VisibilityTimeout'] = timeout.to_s if timeout
-
- response = make_request('ReceiveMessage', "#{queue.queue_url}", params)
- response.nodes("//Message").collect{ |n| Message.from_element n, response, queue } unless response.nil?
- end
-
- def delete_message message
- response = make_request('DeleteMessage', "#{message.queue.queue_url}", {'ReceiptHandle'=>message.receipt_handle})
- end
-
- def make_request(action, url=nil, params = {})
- # puts "make_request a=#{action} u=#{url} p=#{params}"
- url ||= @aws_url
-
- # Add Actions
- params['Action'] = action
- params['Version'] = @aws_version
- params['AWSAccessKeyId'] = @access_key_id
- params['Expires']= (Time.now + @request_expires).gmtime.iso8601
- params['SignatureVersion'] = '1'
-
- # Sign the string
- sorted_params = params.sort_by { |key,value| key.downcase }
- joined_params = sorted_params.collect { |key, value| key.to_s + value.to_s }
- string_to_sign = joined_params.to_s
- digest = OpenSSL::Digest::Digest.new('sha1')
- hmac = OpenSSL::HMAC.digest(digest, @secret_access_key, string_to_sign)
- params['Signature'] = Base64.encode64(hmac).chomp
-
- # Construct request
- query_params = params.collect { |key, value| key + "=" + CGI.escape(value.to_s) }.join("&")
-
- # Put these together to get the request query string
- request_url = "#{url}?#{query_params}"
- # puts "request_url = #{request_url}"
- request = Net::HTTP::Get.new(request_url)
-
- retry_count = 0
- while retry_count < @request_retry_count.to_i
- retry_count = retry_count + 1
- # puts "make_request try retry_count=#{retry_count}"
- begin
- response = SQSResponse.new(http_request(host,port,request))
- check_errors(response)
- return response
- rescue Object=>ex
- # puts "make_request caught #{ex}"
- raise ex unless reliable
- sleep(@reconnect_delay)
- end
- end
- end
-
- # I wrap this so I can move to a different client, or easily mock for testing
- def http_request h, p, r
- return Net::HTTP.start(h, p){ |http| http.request(r) }
- end
-
- def check_errors(response)
- raise "http response was nil" if (response.nil?)
- raise response.errors if (response && response.errors?)
- response
- end
-
- private
-
- # internal data structure methods
- def add_queue(url)
- q = Queue.from_url url
- queues[q.name] = q if self.cache_queue_list
- return q
- end
-
- def get_or_create_queue queue_name
- qs = queues
- qs.has_key?(queue_name) ? qs[queue_name] : create_queue(queue_name)
- end
-
- def queues
- return @queues if (@queues && cache_queue_list)
- @queues = {}
- list_queues.each{|q| @queues[q.name]=q }
- return @queues
- end
-
- # validation methods
- def validate_queue_name qn
- raise "Queue name, '#{qn}', must be between #{QUEUE_NAME_LENGTH.min} and #{QUEUE_NAME_LENGTH.max} characters." unless QUEUE_NAME_LENGTH.include?(qn.length)
- raise "Queue name, '#{qn}', must be alphanumeric only." if (qn =~ /[^\w\-\_]/ )
- end
-
- def validate_new_queue qn
- validate_queue_name qn
- raise "Queue already exists: #{qn}" if queues.has_key? qn
- end
-
- def validate_queue q
- raise "Never heard of queue, can't use it: #{q.name}" unless queues.has_key? q.name
- end
-
- def validate_message m
- raise "Message cannot be nil." if m.nil?
- raise "Message length, #{m.length}, must be between #{MESSAGE_SIZE.min} and #{MESSAGE_SIZE.max}." unless MESSAGE_SIZE.include?(m.length)
- end
-
- def validate_timeout to
- raise "Timeout, #{to}, must be between #{VISIBILITY_TIMEOUT.min} and #{VISIBILITY_TIMEOUT.max}." unless VISIBILITY_TIMEOUT.include?(to)
- end
-
- def validate_get_queue_attribute qa
- raise "Queue Attribute name, #{qa}, not in list of valid attributes to get: #{GET_QUEUE_ATTRIBUTES.to_sentence}." unless GET_QUEUE_ATTRIBUTES.include?(qa)
- end
-
- def validate_set_queue_attribute qa
- raise "Queue Attribute name, #{qa}, not in list of valid attributes to set: #{SET_QUEUE_ATTRIBUTES.to_sentence}." unless SET_QUEUE_ATTRIBUTES.include?(qa)
- end
-
- def validate_number_of_messages nom
- raise "Number of messages, #{nom}, must be between #{NUMBER_OF_MESSAGES.min} and #{NUMBER_OF_MESSAGES.max}." unless NUMBER_OF_MESSAGES.include?(nom)
- end
-
- end
-
- class SQSResponse
- attr_accessor :headers, :doc, :http_response
-
- def initialize response
- # puts "response.body = #{response.body}"
- @http_response = response
- @headers = response.to_hash()
- @doc = REXML::Document.new(response.body)
- end
-
- def message_type
- return doc ? doc.root.name : ''
- end
-
- def errors?
- (not http_response.kind_of?(Net::HTTPSuccess)) or (message_type == "ErrorResponse")
- end
-
- def errors
- return "HTTP Error: #{http_response.code} : #{http_response.message}" unless http_response.kind_of?(Net::HTTPSuccess)
-
- msg = nil
- each_node('//Error') { |n|
- msg ||= ""
- c = n.elements['Code'].text
- m = n.elements['Message'].text
- msg << ", " if msg != ""
- msg << "#{c} : #{m}"
- }
-
- return msg
- end
-
- def get_text(xpath,default='')
- e = REXML::XPath.first( doc, xpath)
- e.nil? ? default : e.text
- end
-
- def each_node(xp)
- REXML::XPath.each(doc.root, xp) {|n| yield n}
- end
-
- def nodes(xp)
- doc.elements.to_a(xp)
- end
- end
-
- class Subscription
- attr_accessor :name, :headers, :count
-
- def initialize(destination, headers={}, count=1)
- @destination, @headers, @count = destination, headers, count
- end
-
- def add
- @count += 1
- end
-
- def remove
- @count -= 1
- end
-
- end
-
- class Queue
- attr_accessor :name, :pathinfo, :domain, :visibility_timeout
-
- def self.from_url url
- return Queue.new($2,$1) if (url =~ /^http:\/\/(.+)\/([-a-zA-Z0-9_]+)$/)
- raise "Bad Queue URL: #{url}"
- end
-
- def queue_url
- "#{pathinfo}/#{name}"
- end
-
- def initialize name, domain, vt=nil
- @name, @pathinfo, @domain, @visibility_timeout = name, pathinfo, domain, vt
- end
-
- def to_s
- "<AmazonSQS::Queue name='#{name}' url='#{queue_url}' domain='#{domain}'>"
- end
- end
-
- # based on stomp message, has pointer to the SQSResponseObject
- class Message
- attr_accessor :headers, :id, :body, :command, :response, :queue, :md5_of_body, :receipt_handle
-
- def self.from_element e, response, queue
- Message.new(response.headers, e.elements['MessageId'].text, e.elements['Body'].text, e.elements['MD5OfBody'].text, e.elements['ReceiptHandle'].text, response, queue)
- end
-
- def initialize headers, id, body, md5_of_body, receipt_handle, response, queue, command='MESSAGE'
- @headers, @id, @body, @md5_of_body, @receipt_handle, @response, @queue, @command = headers, id, body, md5_of_body, receipt_handle, response, queue, command
- headers['destination'] = queue.name
- end
-
-
- def to_s
- "<AmazonSQS::Message id='#{id}' body='#{body}' headers='#{headers.inspect}' command='#{command}' response='#{response}'>"
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/base.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/base.rb
deleted file mode 100644
index 874cd69..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/base.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-module ActiveMessaging
- module Adapters
- module Base
-
-
- # use this as a base for implementing new connections
- class Connection
- include ActiveMessaging::Adapter
-
- #use the register method to add the adapter to the configurable list of supported adapters
- # register :generic
-
- #configurable params
- attr_accessor :reliable
-
- #generic init method needed by a13g
- def initialize cfg
- end
-
- # called to cleanly get rid of connection
- def disconnect
- end
-
- # destination_name string, headers hash
- # subscribe to listen on a destination
- def subscribe destination_name, message_headers={}
- end
-
- # destination_name string, headers hash
- # unsubscribe to listen on a destination
- def unsubscribe destination_name, message_headers={}
- end
-
- # destination_name string, body string, headers hash
- # send a single message to a destination
- def send destination_name, message_body, message_headers={}
- end
-
- # receive a single message from any of the subscribed destinations
- # check each destination once, then sleep for poll_interval
- def receive
- end
-
- # called after a message is successfully received and processed
- def received message, headers={}
- end
-
- # called after a message is successfully received but unsuccessfully processed
- # purpose is to return the message to the destination so receiving and processing and be attempted again
- def unreceive message, headers={}
- end
-
- end
-
- # I recommend having a destination object to represent each subscribed destination
- class Destination
- attr_accessor :name
-
- def to_s
- "<Base::Destination name='#{name}'>"
- end
- end
-
- # based on stomp message
- # command = MESSAGE for successful message from adapter, ERROR for problem from adapter
- # !!!! must have headers['destination'] = subscription.destination in order to match message to subscription in gateway!!!!
- class Message
- attr_accessor :headers, :body, :command
-
- def initialize headers, id, body, response, destination, command='MESSAGE'
- @headers, @body, @command = headers, body, command
- headers['destination'] = destination.name
- end
-
- def to_s
- "<Base::Message body='#{body}' headers='#{headers.inspect}' command='#{command}' >"
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/jms.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/jms.rb
deleted file mode 100644
index 6b4b544..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/jms.rb
+++ /dev/null
@@ -1,237 +0,0 @@
-
-if defined?(JRUBY_VERSION)
-#require 'java'
-include Java
-
-import javax.naming.InitialContext
-import javax.jms.MessageListener
-
-module ActiveMessaging
- module Adapters
- module Jms
-
- class Connection
- include ActiveMessaging::Adapter
- register :jms
-
- attr_accessor :reliable, :connection, :session, :producers, :consumers
-
- def initialize cfg={}
- @url = cfg[:url]
- @login = cfg[:login]
- @passcode = cfg[:passcode]
- #initialize our connection factory
- if cfg.has_key? :connection_factory
- #this initialize is probably activemq specific. There might be a more generic
- #way of getting this without resorting to jndi lookup.
- eval <<-end_eval
- @connection_factory = Java::#{cfg[:connection_factory]}.new(@login, @password, @url)
- end_eval
- elsif cfg.has_key? :jndi
- @connection_factory = javax.naming.InitialContext.new().lookup(cfg[:jndi])
- else
- raise "Either jndi or connection_factory has to be set in the config."
- end
- raise "Connection factory could not be initialized." if @connection_factory.nil?
-
- @connection = @connection_factory.create_connection()
- @session = @connection.createSession(false, 1)
- @destinations = []
- @producers = {}
- @consumers = {}
- @connection.start
- end
-
- def subscribe queue_name, headers={}
- queue_name = check_destination_type queue_name, headers
- find_or_create_consumer queue_name, headers
- end
-
- def unsubscribe queue_name, headers={}
- queue_name = check_destination_type queue_name, headers
- consumer = @consumers[queue_name]
- unless consumer.nil?
- consumer.close
- @consumers.delete queue_name
- end
- end
-
- def send queue_name, body, headers={}
- queue_name = check_destination_type queue_name, headers
- producer = find_or_create_producer queue_name, headers.symbolize_keys
- message = @session.create_text_message body
- headers.stringify_keys.each do |key, value|
- if ['id', 'message-id', 'JMSMessageID'].include? key
- message.setJMSMessageID value.to_s
- elsif ['correlation-id', 'JMSCorrelationID'].include? key
- message.setJMSCorrelationID value.to_s
- elsif ['expires', 'JMSExpiration'].include? key
- message.setJMSExpiration value.to_i
- elsif ['persistent', 'JMSDeliveryMode'].include? key
- message.setJMSDeliveryMode(value ? 2 : 1)
- elsif ['priority', 'JMSPriority'].include? key
- message.setJMSPriority value.to_i
- elsif ['reply-to', 'JMSReplyTo'].include? key
- message.setJMSReplyTo value.to_s
- elsif ['type', 'JMSType'].include? key
- message.setJMSType value.to_s
- else #is this the most appropriate thing to do here?
- message.set_string_property key, value.to_s
- end
- end
- producer.send message
- end
-
- def receive_any
- @consumers.find do |k, c|
- message = c.receive(1)
- return condition_message(message) unless message.nil?
- end
- end
-
- def receive queue_name=nil, headers={}
- if queue_name.nil?
- receive_any
- else
- consumer = subscribe queue_name, headers
- message = consumer.receive(1)
- unsubscribe queue_name, headers
- condition_message message
- end
- end
-
- def received message, headers={}
- #do nothing
- end
-
- def unreceive message, headers={}
- # do nothing
- end
-
- def close
- @consumers.each {|k, c| c.stop }
- @connection.stop
- @session.close
- @connection.close
- @connection = nil
- @session = nil
- @consumers = {}
- @producers = {}
- end
-
- def find_or_create_producer queue_name, headers={}
- producer = @producers[queue_name]
- if producer.nil?
- destination = find_or_create_destination queue_name, headers
- producer = @session.create_producer destination
- end
- producer
- end
-
- def find_or_create_consumer queue_name, headers={}
- consumer = @consumers[queue_name]
- if consumer.nil?
- destination = find_or_create_destination queue_name, headers
- if headers.symbolize_keys.has_key? :selector
- consumer = @session.create_consumer destination, headers.symbolize_keys[:selector]
- else
- consumer = @session.create_consumer destination
- end
-
- @consumers[queue_name] = consumer
- end
- consumer
- end
-
- def find_or_create_destination queue_name, headers={}
- destination = find_destination queue_name, headers[:destination_type]
- if destination.nil?
- if headers.symbolize_keys[:destination_type] == :topic
- destination = @session.create_topic(queue_name.to_s)
- @destinations << destination
- elsif headers.symbolize_keys[:destination_type] == :queue
- destination = @session.create_queue(queue_name.to_s)
- @destinations << destination
- else
- raise "headers[:destination_type] must be either :queue or :topic. was #{headers[:destination_type]}"
- end
- end
- destination
- end
-
- protected
-
- def condition_message message
- message.class.class_eval {
- alias_method :body, :text unless method_defined? :body
-
- def command
- "MESSAGE"
- end
-
- def headers
- destination.to_s =~ %r{(queue|topic)://(.*)}
- puts "/#{$1}/#{$2}"
- {'destination' => "/#{$1}/#{$2}"}
- end
-
- } unless message.nil? || message.respond_to?(:command)
- message
- end
-
- def check_destination_type queue_name, headers
- stringy_h = headers.stringify_keys
- if queue_name =~ %r{^/(topic|queue)/(.*)$} && !stringy_h.has_key?('destination_type')
- headers['destination_type'] = $1.to_sym
- return $2
- else
- raise "Must specify destination type either with either 'headers[\'destination_type\']=[:queue|:topic]' or /[topic|queue]/destination_name for queue name '#{queue_name}'" unless [:topic, :queue].include? stringy_h['destination_type']
- end
- end
-
- def find_destination queue_name, type
- @destinations.find do |d|
- if d.is_a?(javax.jms.Topic) && type == :topic
- d.topic_name == queue_name
- elsif d.is_a?(javax.jms.Queue) && type == :queue
- d.queue_name == queue_name
- end
- end
- end
- end
-#
-# class RubyMessageListener
-# include javax.jms.MessageListener
-#
-# def initialize(connection, destination, name)
-# @connection = connection
-# @destination = destination
-# @name = name
-# end
-#
-# def onMessage(msg)
-# headers = {}
-# enm = msg.getPropertyNames
-# while enm.hasMoreElements
-# key = enm.nextElement
-# headers[key.to_s] = msg.getStringProperty(key)
-# end
-# Gateway.dispatch(JMSRecvMessage.new(headers,msg.text,@name))
-# rescue => e
-# STDERR.puts "something went really wrong with a message: #{e.inspect}"
-# end
-# end
-#
-# class JMSRecvMessage < ActiveMessaging::Adapters::Base::Message
-# def initialize(headers, body, name, command='MESSAGE')
-# @headers = headers
-# @body = body
-# @command = command
-# @headers['destination'] = name
-# end
-# end
- end
- end
-end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/reliable_msg.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/reliable_msg.rb
deleted file mode 100644
index af38d4e..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/reliable_msg.rb
+++ /dev/null
@@ -1,190 +0,0 @@
-require 'reliable-msg'
-
-module ReliableMsg
-
- class Client
-
- def queue_manager
- qm
- end
-
- end
-end
-
-
-module ActiveMessaging
- module Adapters
- module ReliableMsg
-
- THREAD_OLD_TXS = :a13g_reliable_msg_old_txs
-
- QUEUE_PARAMS = [:expires,:delivery,:priority,:max_deliveries,:drb_uri,:tx_timeout,:connect_count]
- TOPIC_PARAMS = [:expires,:drb_uri,:tx_timeout,:connect_count]
-
- class Connection
- include ActiveMessaging::Adapter
-
- register :reliable_msg
-
- #configurable params
- attr_accessor :reliable, :subscriptions, :destinations, :poll_interval, :current_subscription, :tx_timeout
-
- #generic init method needed by a13g
- def initialize cfg
- @poll_interval = cfg[:poll_interval] || 1
- @reliable = cfg[:reliable] || true
- @tx_timeout = cfg[:tx_timeout] || ::ReliableMsg::Client::DEFAULT_TX_TIMEOUT
-
- @subscriptions = {}
- @destinations = {}
- @current_subscription = 0
- end
-
- # called to cleanly get rid of connection
- def disconnect
- nil
- end
-
- # destination_name string, headers hash
- # subscribe to listen on a destination
- # use '/destination-type/name' convetion, like stomp
- def subscribe destination_name, message_headers={}
- get_or_create_destination(destination_name, message_headers)
- if subscriptions.has_key? destination_name
- subscriptions[destination_name].add
- else
- subscriptions[destination_name] = Subscription.new(destination_name, message_headers)
- end
- end
-
- # destination_name string, headers hash
- # unsubscribe to listen on a destination
- def unsubscribe destination_name, message_headers={}
- subscriptions[destination_name].remove
- subscriptions.delete(destination_name) if subscriptions[destination_name].count <= 0
- end
-
- # destination_name string, body string, headers hash
- # send a single message to a destination
- def send destination_name, message_body, message_headers={}
- dest = get_or_create_destination(destination_name)
- begin
- dest.put message_body, message_headers
- rescue Object=>err
- raise err unless reliable
- puts "send failed, will retry in #{@poll_interval} seconds"
- sleep @poll_interval
- end
- end
-
- def get_or_create_destination destination_name, message_headers={}
- return destinations[destination_name] if destinations.has_key? destination_name
- dd = /^\/(queue|topic)\/(.*)$/.match(destination_name)
- rm_class = dd[1].titleize
- message_headers.delete("id")
- dest_headers = message_headers.reject {|k,v| rm_class == 'Queue' ? !QUEUE_PARAMS.include?(k) : !TOPIC_PARAMS.include?(k)}
- rm_dest = "ReliableMsg::#{rm_class}".constantize.new(dd[2], dest_headers)
- destinations[destination_name] = rm_dest
- end
-
- # receive a single message from any of the subscribed destinations
- # check each destination once, then sleep for poll_interval
- def receive
-
- raise "No subscriptions to receive messages from." if (subscriptions.nil? || subscriptions.empty?)
- start = current_subscription
- while true
- self.current_subscription = ((current_subscription < subscriptions.length-1) ? current_subscription + 1 : 0)
- sleep poll_interval if (current_subscription == start)
- destination_name = subscriptions.keys.sort[current_subscription]
- destination = destinations[destination_name]
- unless destination.nil?
- # from the way we use this, assume this is the start of a transaction,
- # there should be no current transaction
- ctx = Thread.current[::ReliableMsg::Client::THREAD_CURRENT_TX]
- raise "There should not be an existing reliable-msg transaction. #{ctx.inspect}" if ctx
-
- # start a new transaction
- @tx = {:qm=>destination.queue_manager}
- @tx[:tid] = @tx[:qm].begin @tx_timeout
- Thread.current[::ReliableMsg::Client::THREAD_CURRENT_TX] = @tx
- begin
-
- # now call a get on the destination - it will use the transaction
- #the commit or the abort will occur in the received or unreceive methods
- reliable_msg = destination.get subscriptions[destination_name].headers[:selector]
- @tx[:qm].commit(@tx[:tid]) if reliable_msg.nil?
-
- rescue Object=>err
- #abort the transaction on error
- @tx[:qm].abort(@tx[:tid])
-
- raise err unless reliable
- puts "receive failed, will retry in #{@poll_interval} seconds"
- sleep poll_interval
- end
- return Message.new(reliable_msg.id, reliable_msg.object, reliable_msg.headers, destination_name, 'MESSAGE', @tx) if reliable_msg
-
- Thread.current[::ReliableMsg::Client::THREAD_CURRENT_TX] = nil
- end
- end
- end
-
- # called after a message is successfully received and processed
- def received message, headers={}
- begin
- message.transaction[:qm].commit(message.transaction[:tid])
- rescue Object=>ex
- puts "received failed: #{ex.message}"
- ensure
- Thread.current[::ReliableMsg::Client::THREAD_CURRENT_TX] = nil
- end
-
- end
-
- # called after a message is successfully received and processed
- def unreceive message, headers={}
- begin
- message.transaction[:qm].abort(message.transaction[:tid])
- rescue Object=>ex
- puts "unreceive failed: #{ex.message}"
- ensure
- Thread.current[::ReliableMsg::Client::THREAD_CURRENT_TX] = nil
- end
- end
-
- end
-
- class Subscription
- attr_accessor :name, :headers, :count
-
- def initialize(destination, headers={}, count=1)
- @destination, @headers, @count = destination, headers, count
- end
-
- def add
- @count += 1
- end
-
- def remove
- @count -= 1
- end
-
- end
-
- class Message
- attr_accessor :id, :body, :headers, :command, :transaction
-
- def initialize id, body, headers, destination_name, command='MESSAGE', transaction=nil
- @id, @body, @headers, @command, @transaction = id, body, headers, command, transaction
- headers['destination'] = destination_name
- end
-
- def to_s
- "<ReliableMessaging::Message id='#{id}' body='#{body}' headers='#{headers.inspect}' command='#{command}' >"
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/stomp.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/stomp.rb
deleted file mode 100644
index 8a05ac5..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/stomp.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-require 'stomp'
-
-module ActiveMessaging
- module Adapters
- module Stomp
-
- class Connection < ::Stomp::Connection
- include ActiveMessaging::Adapter
- register :stomp
-
- attr_accessor :reliable, :retryMax, :deadLetterQueue
-
- def initialize(cfg)
- @retryMax = cfg[:retryMax] || 0
- @deadLetterQueue = cfg[:deadLetterQueue] || nil
-
- cfg[:login] ||= ""
- cfg[:passcode] ||= ""
- cfg[:host] ||= "localhost"
- cfg[:port] ||= "61613"
- cfg[:reliable] ||= TRUE
- cfg[:reconnectDelay] ||= 5
- cfg[:clientId] ||= nil
-
- if cfg[:clientId]
- super(cfg[:login],cfg[:passcode],cfg[:host],cfg[:port].to_i,cfg[:reliable],cfg[:reconnectDelay],cfg[:clientId])
- else
- super(cfg[:login],cfg[:passcode],cfg[:host],cfg[:port].to_i,cfg[:reliable],cfg[:reconnectDelay])
- end
-
- end
-
- def received message, headers={}
- #check to see if the ack mode for this subscription is auto or client
- # if the ack mode is client, send an ack
- if (headers[:ack] === 'client')
- ack_headers = message.headers.has_key?(:transaction) ? message.headers[:transaction] : {}
- ack message.headers['message-id'], ack_headers
- end
- end
-
- def unreceive message, headers={}
- retry_count = message.headers['a13g-retry-count'].to_i || 0
- transaction_id = "transaction-#{message.headers['message-id']}-#{retry_count}"
-
- # start a transaction, send the message back to the original destination
- self.begin(transaction_id)
- begin
-
- if @retryMax > 0
- retry_headers = message.headers.stringify_keys
- retry_headers['transaction']= transaction_id
- retry_headers.delete('content-length')
- retry_headers.delete('content-type')
-
- if retry_count < @retryMax
- # now send the message back to the destination
- # set the headers for message id, priginal message id, and retry count
- retry_headers['a13g-original-message-id'] = retry_headers['message-id'] unless retry_headers.has_key?('a13g-original-message-id')
- retry_headers.delete('message-id')
-
- retry_headers['a13g-original-timestamp'] = retry_headers['timestamp'] unless retry_headers.has_key?('a13g-original-timestamp')
- retry_headers.delete('timestamp')
-
- retry_headers['a13g-retry-count'] = retry_count + 1
-
- # send the updated message to retry in the same transaction
- self.send retry_headers['destination'], message.body, retry_headers
-
- elsif retry_count >= @retryMax && @deadLetterQueue
- # send the 'poison pill' message to the dead letter queue
- retry_headers['a13g-original-destination'] = retry_headers.delete('destination')
- retry_headers.delete('message-id')
- self.send @deadLetterQueue, message.body, retry_headers
- end
- elsif @deadLetterQueue
- retry_headers = message.headers.stringify_keys
- retry_headers['transaction']= transaction_id
- retry_headers.delete('content-length')
- retry_headers.delete('content-type')
- # send the 'poison pill' message to the dead letter queue
- retry_headers['a13g-original-destination'] = retry_headers.delete('destination')
- retry_headers.delete('message-id')
- self.send(@deadLetterQueue, message.body, retry_headers)
- end
-
- #check to see if the ack mode is client, and if it is, ack it in this transaction
- if (headers[:ack] === 'client')
- # ack the original message
- self.ack message.headers['message-id'], message.headers.stringify_keys.merge('transaction'=>transaction_id)
- end
-
- # now commit the transaction
- self.commit transaction_id
- rescue Exception=>exc
- # if there is an error, try to abort the transaction, then raise the error
- self.abort transaction_id
- raise exc
- end
-
- end
-
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/test.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/test.rb
deleted file mode 100644
index 837fa18..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/test.rb
+++ /dev/null
@@ -1,159 +0,0 @@
-
-module ActiveMessaging
- module Adapters
- module Test
-
- class Connection
- include ActiveMessaging::Adapter
- register :test
-
- attr_accessor :config, :subscriptions, :destinations, :connected, :received_messages, :unreceived_messages
-
- def initialize cfg
- @config = cfg
- @subscriptions = []
- @destinations = []
- @received_messages = []
- @unreceived_messages = []
- @connected = true
- end
-
- def disconnect
- @subscriptions = []
- @destinations = []
- @received_messages = []
- @unreceived_messages = []
- @connected = false
- end
-
- def subscribe destination_name, subscribe_headers={}
- open_destination destination_name
- unless @subscriptions.find {|s| s.name == destination_name}
- @subscriptions << Subscription.new(destination_name, subscribe_headers)
- end
- @subscriptions.last
- end
-
- def unsubscribe destination_name, unsubscribe_headers={}
- @subscriptions.delete_if {|s| s.name == destination_name}
- end
-
- def send destination_name, message_body, message_headers={}
- open_destination destination_name
- destination = find_destination destination_name
- destination.send Message.new(message_headers, nil, message_body, nil, destination)
- end
-
- def receive
- destination = @destinations.find do |q|
- find_subscription(q.name) && !q.empty?
- end
- destination.receive unless destination.nil?
- end
-
- # should not be 2 defs for receive, this isn't java, ya know? -Andrew
- # def receive destination_name, headers={}
- # subscribe destination_name, headers
- # destination = find_destination destination_name
- # message = destination.receive
- # unsubscribe destination_name, headers
- # message
- # end
-
- def received message, headers={}
- @received_messages << message
- end
-
- def unreceive message, headers={}
- @unreceived_messages << message
- end
-
- #test helper methods
- def find_message destination_name, body
- all_messages.find do |m|
- m.headers['destination'] == destination_name && if body.is_a?(Regexp)
- m.body =~ body
- else
- m.body == body.to_s
- end
- end
- end
-
- # Method added by Marius Mathiesen. Clears the messages for easier testing
- def clear_messages
- @destinations.each{|d|d.messages.clear}
- end
-
- def open_destination destination_name
- unless find_destination destination_name
- @destinations << Destination.new(destination_name)
- end
- end
-
- def find_destination destination_name
- @destinations.find{|q| q.name == destination_name }
- end
-
- def find_subscription destination_name
- @subscriptions.find{|s| s.name == destination_name}
- end
-
- def all_messages
- @destinations.map {|q| q.messages }.flatten
- end
- end
-
- class Destination
-
- attr_accessor :name, :messages
-
- def initialize name
- @name = name
- @messages = []
- end
-
- def receive
- @messages.shift
- end
-
- def send message
- @messages << message
- end
-
- def empty?
- @messages.empty?
- end
-
- def to_s
- "<Test::Destination name='#{name}' messages='#{@messages.inspect}'>"
- end
- end
-
- class Subscription
- attr_accessor :name, :headers
-
- def initialize name, headers
- @name = name
- @headers = headers
- end
-
- def to_s
- "<Test::Subscription destination='#{name}' headers='#{headers.inspect}' >"
- end
- end
-
- class Message
- attr_accessor :headers, :body, :command
-
- def initialize headers, id, body, response, destination, command='MESSAGE'
- @headers, @body, @command = headers, body, command
- headers['destination'] = destination.name
- end
-
- def to_s
- "<Test::Message body='#{body}' headers='#{headers.inspect}' command='#{command}' >"
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/adapters/wmq.rb b/vendor/plugins/activemessaging/lib/activemessaging/adapters/wmq.rb
deleted file mode 100644
index 085aa57..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/adapters/wmq.rb
+++ /dev/null
@@ -1,202 +0,0 @@
-################################################################################
-# Copyright 2007 S. Perez. RBC Dexia Investor Servies Bank
-#
-# 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.
-################################################################################
-
-#
-# WebSphere MQ adapter for activemessaging
-#
-require 'wmq/wmq'
-
-module ActiveMessaging
- module Adapters
- module Adapter
-
- # Connection class needed by a13g
- class Connection
- include ActiveMessaging::Adapter
- register :wmq
-
- # Needed by a13g but never used within this adapter
- attr_accessor :reliable
-
- # Generic init method needed by a13g
- def initialize(cfg)
- # Set default values
- cfg[:poll_interval] ||= 0.1
-
- # Initialize instance members
- # Trick for the connection_options is to allow settings WMQ constants directly in broker.yml :))
- @connection_options = cfg.each_pair {|key, value| cfg[key] = instance_eval(value) if (value.instance_of?(String) && value.match("WMQ::")) }
- @queue_names = []
- @current_queue = 0
- @queues = {}
- end
-
- # Disconnect method needed by a13g
- # No need to disconnect from the queue manager since connection and disconnection occurs inside the send and receive methods
- # headers is never used
- def disconnect(headers = {})
- end
-
- # Receive method needed by a13g
- def receive
- raise "No subscription to receive messages from" if (@queue_names.nil? || @queue_names.empty?)
- start = @current_queue
- while true
- @current_queue = ((@current_queue < @queue_names.length-1) ? @current_queue + 1 : 0)
- sleep(@connection_options[:poll_interval]) if (@current_queue == start)
- q = @queues[@queue_names[@current_queue]]
- unless q.nil?
- message = retrieve_message(q)
- return message unless message.nil?
- end
- end
- end
-
- # Send method needed by a13g
- # headers may contains 2 different hashes to gives more control over the sending process
- # :descriptor => {...} to populate the descriptor of the message
- # :put_options => {...} to specify the put options for that message
- def send(q_name, message_data, headers={})
- WMQ::QueueManager.connect(@connection_options) do |qmgr|
- qmgr.open_queue(:q_name => q_name, :mode => :output) do |queue|
-
- message_descriptor = headers[:descriptor] || {:format => WMQ::MQFMT_STRING}
- put_options = headers[:put_options].nil? ? {} : headers[:put_options].dup
-
- wmq_message = WMQ::Message.new(:data => message_data, :descriptor => message_descriptor)
- queue.put(put_options.merge(:message => wmq_message, :data => nil))
- return Message.new(wmq_message, q_name)
- end
- end
- end
-
- # Subscribe method needed by a13g
- # headers may contains a hash to give more control over the get operation on the queue
- # :get_options => {...} to specify the get options when receiving messages
- # Warning : get options are set only on the first queue subscription and are common to all the queue's subscriptions
- # Any other get options passed with subsequent subscribe on an existing queue will be discarded
- # subId is never used
- def subscribe(q_name, headers={}, subId=NIL)
- if @queues[q_name].nil?
- get_options = headers[:get_options] || {}
- q = Queue.new(q_name, get_options)
- @queues[q_name] = q
- @queue_names << q.name
- end
-
- q.add_subscription
- end
-
- # Unsubscribe method needed by a13g
- # Stop listening the queue only after the last unsubscription
- # headers is never used
- # subId is never used
- def unsubscribe(q_name, headers={}, subId=NIL)
- q = @queues[q_name]
- unless q.nil?
- q.remove_subscription
- unless q.has_subscription?
- @queues.delete(q_name)
- @queue_names.delete(q_name)
- end
- end
- end
-
- # called after a message is successfully received and processed
- def received message, headers={}
- end
-
- # called after a message is successfully received but unsuccessfully processed
- # purpose is to return the message to the destination so receiving and processing and be attempted again
- def unreceive message, headers={}
- end
-
- private
-
- # Retrieve the first available message from the specicied queue
- # Return nil if queue is empty
- def retrieve_message(q)
- WMQ::QueueManager.connect(@connection_options) do |qmgr|
- qmgr.open_queue(:q_name => q.name, :mode => :input) do |queue|
-
- get_options = q.get_options.dup
- wmq_message = WMQ::Message.new
-
- if queue.get(get_options.merge(:message => wmq_message))
- return Message.new(wmq_message, q.name)
- else
- return nil
- end
- end
- end
- end
- end
-
- # Message class needed by a13g (based on the same Message class in Stomp adapter)
- # Contains a reference to the MQ message object ;-) !
- class Message
- # Accessors needed by a13g
- attr_accessor :headers, :body, :command, :wmq_message
-
- def initialize(wmq_message, q_name)
- @wmq_message = wmq_message
-
- # Needed by a13g
- @headers = {'destination' => q_name}
- @body = wmq_message.data
- @command = 'MESSAGE'
- end
-
- def to_s
- "<Adapter::Message headers=#{@headers.inspect} body='#{@body}' command='#{@command}' wmq_message=#{@wmq_message}>"
- end
- end
-
- private
-
- # Queue class is used to keep track of the subscriptions
- # It contains :
- # - name of the queue
- # - options to use when getting from the queue
- # - number of subscriptions
- class Queue
- attr_accessor :name, :get_options, :nb_subscriptions
-
- def initialize(name, get_options)
- @name, @get_options = name, get_options
- @nb_subscriptions = 0
- end
-
- def add_subscription
- @nb_subscriptions += 1
- end
-
- def remove_subscription
- @nb_subscriptions -= 1 unless @nb_subscriptions > 0
- end
-
- def has_subscription?
- @nb_subscriptions > 0
- end
-
- def to_s
- "<Adapter::Queue name='#{@name}' get_options=#{@get_options} nb_subscriptions=#{@nb_subscriptions}>"
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/filter.rb b/vendor/plugins/activemessaging/lib/activemessaging/filter.rb
deleted file mode 100644
index 5fbff82..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/filter.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# 'abstract' base class for ActiveMessaging filter classes
-module ActiveMessaging
- class Filter
-
- #automatically make it so filters are message senders
- include MessageSender
-
- # give filters easy access to the logger
- def logger()
- @@logger = ActiveMessaging.logger unless defined?(@@logger)
- @@logger
- end
-
- # these are the headers available for a message from the 'details' hash
- # :receiver=>processor
- # :destination=>destination object
- # :direction => :incoming
-
- # :publisher => publisher - optional
- # :destination => destination object
- # :direction => :outgoing
-
- # if you raise a StopProcessingException, it will cause this to be the last filter to be processed, and will prevent any further processing
- def process(message, routing)
- raise NotImplementedError.new("Implement the process method in your own filter class that extends ActiveMessaging::Filter")
- end
-
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb b/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb
deleted file mode 100644
index 35a86ed..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb
+++ /dev/null
@@ -1,414 +0,0 @@
-require 'yaml'
-
-module ActiveMessaging
-
- class Gateway
- cattr_accessor :adapters, :subscriptions, :named_destinations, :filters, :processor_groups, :connections
- @@adapters = {}
- @@subscriptions = {}
- @@named_destinations = {}
- @@filters = []
- @@connections = {}
- @@processor_groups = {}
- @@current_processor_group = nil
-
- # these are used to manage the running connection threads
- @@running = true
- @@connection_threads = {}
- @@guard = Mutex.new
-
- class <<self
-
- # Starts up an message listener to start polling for messages on each configured connection, and dispatching processing
- def start
-
- # subscribe - creating connections along the way
- subscribe
-
- # for each connection, start a thread
- @@connections.each do |name, conn|
- @@connection_threads[name] = Thread.start do
- while @@running
- begin
- Thread.current[:message] = nil
- Thread.current[:message] = conn.receive
- #catch these but then stop looping
- rescue StopProcessingException=>spe
- ActiveMessaging.logger.error "ActiveMessaging: thread[#{name}]: Processing Stopped - receive interrupted, will process last message if already received"
- # break
- #catch all others, but go back and try and recieve again
- rescue Object=>exception
- ActiveMessaging.logger.error "ActiveMessaging: thread[#{name}]: Exception from connection.receive: #{exception.message}\n" + exception.backtrace.join("\n\t")
- ensure
- dispatch Thread.current[:message] if Thread.current[:message]
- Thread.current[:message] = nil
- end
- Thread.pass
- end
- ActiveMessaging.logger.error "ActiveMessaging: thread[#{name}]: receive loop terminated"
- end
- end
-
- while @@running
- trap("TERM", "EXIT")
- living = false
- @@connection_threads.each { |name, thread| living ||= thread.alive? }
- @@running = living
- sleep 1
- end
- ActiveMessaging.logger.error "All connection threads have died..."
- rescue Interrupt
- ActiveMessaging.logger.error "\n<<Interrupt received>>\n"
- rescue Object=>exception
- ActiveMessaging.logger.error "#{exception.class.name}: #{exception.message}\n\t#{exception.backtrace.join("\n\t")}"
- raise exception
- ensure
- ActiveMessaging.logger.error "Cleaning up..."
- stop
- ActiveMessaging.logger.error "=> END"
- end
-
- def stop
- # first tell the threads to stop their looping, so they'll stop when next complete a receive/dispatch cycle
- @@running = false
-
- # if they are dispatching (i.e. !thread[:message].nil?), wait for them to finish
- # if they are receiving (i.e. thread[:message].nil?), stop them by raising exception
- dispatching = true
- while dispatching
- dispatching = false
- @@connection_threads.each do |name, thread|
- if thread[:message]
- dispatching = true
- # if thread got killed, but dispatch not done, try it again
- if thread.alive?
- ActiveMessaging.logger.error "Waiting on thread #{name} to finish processing last message..."
- else
- ActiveMessaging.logger.error "Starting thread #{name} to finish processing last message..."
- msg = thread[:message]
- thread.exit
- thread = Thread.start do
- begin
- Thread.current[:message] = msg
- dispatch Thread.current[:message]
- ensure
- Thread.current[:message] = nil
- end
- end
- end
- else
- thread.raise StopProcessingException, "Time to stop." if thread.alive?
- end
- end
- sleep(1)
- end
- unsubscribe
- disconnect
- end
-
- def connection broker_name='default'
- return @@connections[broker_name] if @@connections.has_key?(broker_name)
- config = load_connection_configuration(broker_name)
- @@connections[broker_name] = Gateway.adapters[config[:adapter]].new(config)
- end
-
- def register_adapter adapter_name, adapter_class
- adapters[adapter_name] = adapter_class
- end
-
- def filter filter, options = {}
- options[:direction] = :bidirectional if options[:direction].nil?
- filters << [filter, options]
- end
-
- def subscribe
- subscriptions.each { |key, subscription| subscription.subscribe }
- end
-
- def unsubscribe
- subscriptions.each { |key, subscription| subscription.unsubscribe }
- end
-
- def disconnect
- @@connections.each { |key,connection| connection.disconnect }
- @@connections = {}
- end
-
- def execute_filter_chain(direction, message, details={})
- filters.each do |filter, options|
- if apply_filter?(direction, details, options)
- begin
- filter_obj = create_filter(filter, options)
- filter_obj.process(message, details)
- rescue ActiveMessaging::StopFilterException => sfe
- ActiveMessaging.logger.error "Filter: #{filter_obj.inspect} threw StopFilterException: #{sfe.message}"
- return
- end
- end
- end
- yield(message)
- end
-
- def apply_filter?(direction, details, options)
- # check that it is the correct direction
- result = if direction.to_sym == options[:direction] || options[:direction] == :bidirectional
- if options.has_key?(:only) && [options[:only]].flatten.include?(details[:destination].name)
- true
- elsif options.has_key?(:except) && ![options[:except]].flatten.include?(details[:destination].name)
- true
- elsif !options.has_key?(:only) && !options.has_key?(:except)
- true
- end
- end
- result
- end
-
- def create_filter(filter, options)
- filter_class = if filter.is_a?(String) or filter.is_a?(Symbol)
- filter.to_s.camelize.constantize
- elsif filter.is_a?(Class)
- filter
- end
-
- if filter_class
- if filter_class.respond_to?(:process) && (filter_class.method(:process).arity.abs > 0)
- filter_class
- elsif filter_class.instance_method(:initialize).arity.abs == 1
- filter_class.new(options)
- elsif filter_class.instance_method(:initialize).arity == 0
- filter_class.new
- else
- raise "Filter #{filter} could not be created, no 'initialize' matched."
- end
- else
- raise "Filter #{filter} could not be loaded, created, or used!"
- end
- end
-
- def prepare_application
- Dispatcher.prepare_application_for_dispatch
- end
-
- def reset_application
- Dispatcher.reset_application_after_dispatch
- end
-
- def dispatch(message)
- @@guard.synchronize {
- begin
- prepare_application
- _dispatch(message)
- rescue Object => exc
- ActiveMessaging.logger.error "Dispatch exception: #{exc}"
- ActiveMessaging.logger.error exc.backtrace.join("\n\t")
- raise exc
- ensure
- reset_application
- end
- }
- end
-
- def _dispatch(message)
- case message.command
- when 'ERROR'
- ActiveMessaging.logger.error('Error from messaging infrastructure: ' + message.headers['message'])
- when 'MESSAGE'
- abort = false
- processed = false
-
- subscriptions.each do |key, subscription|
- if subscription.matches?(message) then
- processed = true
- routing = {
- :receiver=>subscription.processor_class,
- :destination=>subscription.destination,
- :direction => :incoming
- }
- begin
- execute_filter_chain(:incoming, message, routing) do |m|
- result = subscription.processor_class.new.process!(m)
- end
- rescue ActiveMessaging::AbortMessageException
- abort_message subscription, message
- abort = true
- return
- ensure
- acknowledge_message subscription, message unless abort
- end
- end
- end
-
- ActiveMessaging.logger.error("No-one responded to #{message}") unless processed
- else
- ActiveMessaging.logger.error('Unknown message command: ' + message.inspect)
- end
- end
-
- # acknowledge_message is called when the message has been processed w/o error by at least one processor
- def acknowledge_message subscription, message
- connection(subscription.destination.broker_name).received message, subscription.subscribe_headers
- end
-
- # abort_message is called when procesing the message raises a ActiveMessaging::AbortMessageException
- # indicating the message should be returned to the destination so it can be tried again, later
- def abort_message subscription, message
- connection(subscription.destination.broker_name).unreceive message, subscription.subscribe_headers
- end
-
- def define
- #run the rest of messaging.rb
- yield self
- end
-
- def destination destination_name, destination, publish_headers={}, broker='default'
- raise "You already defined #{destination_name} to #{named_destinations[destination_name].value}" if named_destinations.has_key?(destination_name)
- named_destinations[destination_name] = Destination.new destination_name, destination, publish_headers, broker
- end
-
- alias queue destination
-
- def find_destination destination_name
- real_destination = named_destinations[destination_name]
- raise "You have not yet defined a destination named #{destination_name}. Destinations currently defined are [#{named_destinations.keys.join(',')}]" if real_destination.nil?
- real_destination
- end
-
- alias find_queue find_destination
-
- def subscribe_to destination_name, processor, headers={}
- proc_name = processor.name.underscore
- proc_sym = processor.name.underscore.to_sym
- if (!current_processor_group || processor_groups[current_processor_group].include?(proc_sym))
- @@subscriptions["#{proc_name}:#{destination_name}"]= Subscription.new(find_destination(destination_name), processor, headers)
- end
- end
-
- def publish destination_name, body, publisher=nil, headers={}, timeout=10
- raise "You cannot have a nil or empty destination name." if destination_name.nil?
- raise "You cannot have a nil or empty message body." if (body.nil? || body.empty?)
-
- real_destination = find_destination(destination_name)
- details = {
- :publisher => publisher,
- :destination => real_destination,
- :direction => :outgoing
- }
- message = OpenStruct.new(:body => body, :headers => headers.reverse_merge(real_destination.publish_headers))
- begin
- Timeout.timeout timeout do
- execute_filter_chain(:outgoing, message, details) do |message|
- connection(real_destination.broker_name).send real_destination.value, message.body, message.headers
- end
- end
- rescue Timeout::Error=>toe
- ActiveMessaging.logger.error("Timed out trying to send the message #{message} to destination #{destination_name} via broker #{real_destination.broker_name}")
- raise toe
- end
- end
-
- def receive destination_name, receiver=nil, subscribe_headers={}, timeout=10
- raise "You cannot have a nil or empty destination name." if destination_name.nil?
- conn = nil
- dest = find_destination destination_name
- config = load_connection_configuration(dest.broker_name)
- subscribe_headers['id'] = receiver.name.underscore unless (receiver.nil? or subscribe_headers.key? 'id')
- Timeout.timeout timeout do
- conn = Gateway.adapters[config[:adapter]].new(config)
- conn.subscribe(dest.value, subscribe_headers)
- message = conn.receive
- conn.received message, subscribe_headers
- return message
- end
- rescue Timeout::Error=>toe
- ActiveMessaging.logger.error("Timed out trying to receive a message on destination #{destination_name}")
- raise toe
- ensure
- conn.disconnect unless conn.nil?
- end
-
- def processor_group group_name, *processors
- if processor_groups.has_key? group_name
- processor_groups[group_name] = processor_groups[group_name] + processors
- else
- processor_groups[group_name] = processors
- end
- end
-
- def current_processor_group
- if ARGV.length > 0 && !@@current_processor_group
- ARGV.each {|arg|
- pair = arg.split('=')
- if pair[0] == 'process-group'
- group_sym = pair[1].to_sym
- if processor_groups.has_key? group_sym
- @@current_processor_group = group_sym
- else
- ActiveMessaging.logger.error "Unrecognized process-group."
- ActiveMessaging.logger.error "You specified process-group #{pair[1]}, make sure this is specified in config/messaging.rb"
- ActiveMessaging.logger.error " ActiveMessaging::Gateway.define do |s|"
- ActiveMessaging.logger.error " s.processor_groups = { :group1 => [:foo_bar1_processor], :group2 => [:foo_bar2_processor] }"
- ActiveMessaging.logger.error " end"
- exit
- end
- end
- }
- end
- @@current_processor_group
- end
-
- def load_connection_configuration(label='default')
- @broker_yml = YAML::load(ERB.new(IO.read(File.join(RAILS_ROOT, 'config', 'broker.yml'))).result) if @broker_yml.nil?
- if label == 'default'
- config = @broker_yml[RAILS_ENV].symbolize_keys
- else
- config = @broker_yml[RAILS_ENV][label].symbolize_keys
- end
- config[:adapter] = config[:adapter].to_sym if config[:adapter]
- config[:adapter] ||= :stomp
- return config
- end
-
- end
-
- end
-
- class Subscription
- attr_accessor :destination, :processor_class, :subscribe_headers
-
- def initialize(destination, processor_class, subscribe_headers = {})
- @destination, @processor_class, @subscribe_headers = destination, processor_class, subscribe_headers
- subscribe_headers['id'] = processor_class.name.underscore unless subscribe_headers.key? 'id'
- end
-
- def matches?(message)
- message.headers['destination'].to_s == @destination.value.to_s
- end
-
- def subscribe
- ActiveMessaging.logger.error "=> Subscribing to #{destination.value} (processed by #{processor_class})"
- Gateway.connection(@destination.broker_name).subscribe(@destination.value, subscribe_headers)
- end
-
- def unsubscribe
- ActiveMessaging.logger.error "=> Unsubscribing from #{destination.value} (processed by #{processor_class})"
- Gateway.connection(destination.broker_name).unsubscribe(destination.value, subscribe_headers)
- end
- end
-
- class Destination
- DEFAULT_PUBLISH_HEADERS = { :persistent=>true }
-
- attr_accessor :name, :value, :publish_headers, :broker_name
-
- def initialize(name, value, publish_headers, broker_name)
- @name, @value, @publish_headers, @broker_name = name, value, publish_headers, broker_name
- @publish_headers.reverse_merge! DEFAULT_PUBLISH_HEADERS
- end
-
- def to_s
- "#{broker_name}: #{name} => '#{value}'"
- end
-
- end
-
-end #module
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb b/vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb
deleted file mode 100644
index c36e879..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require 'logger'
-
-module ActiveMessaging
-
- # This is a module so that we can send messages from (for example) web page controllers, or can receive a single message
- module MessageSender
-
- def self.included(included_by)
- class << included_by
- def publishes_to destination_name
- Gateway.find_destination destination_name
- end
-
- def receives_from destination_name
- Gateway.find_destination destination_name
- end
- end
- end
-
- def publish destination_name, message, headers={}, timeout=10
- Gateway.publish(destination_name, message, self.class, headers, timeout)
- end
-
- def receive destination_name, headers={}, timeout=10
- Gateway.receive(destination_name, self.class, headers, timeout)
- end
-
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/processor.rb b/vendor/plugins/activemessaging/lib/activemessaging/processor.rb
deleted file mode 100644
index 3a22aeb..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/processor.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# 'abstract' base class for ActiveMessaging processor classes
-module ActiveMessaging
-
- class Processor
- include MessageSender
-
- attr_reader :message
-
- class<<self
- def subscribes_to destination_name, headers={}
- ActiveMessaging::Gateway.subscribe_to destination_name, self, headers
- end
- end
-
- def logger()
- @@logger = ActiveMessaging.logger unless defined?(@@logger)
- @@logger
- end
-
- def on_message(message)
- raise NotImplementedError.new("Implement the on_message method in your own processor class that extends ActiveMessaging::Processor")
- end
-
- def on_error(exception)
- raise exception
- end
-
- # Bind the processor to the current message so that the processor could
- # potentially access headers and other attributes of the message
- def process!(message)
- @message = message
- return on_message(message.body)
- rescue Object=>err
- begin
- on_error(err, message.body)
- rescue ActiveMessaging::AbortMessageException => rpe
- logger.error "Processor:process! - AbortMessageException caught."
- raise rpe
- rescue Object=>ex
- logger.error "Processor:process! - error in on_error, will propagate no further: #{ex.message}"
- end
- end
-
- end
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/support.rb b/vendor/plugins/activemessaging/lib/activemessaging/support.rb
deleted file mode 100644
index 8bff78b..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/support.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# # experimenting with adding processors to the load paths, doesn't seem to work
-# Dependencies.load_paths += ["#{RAILS_ROOT}/app/processors"]
-
-require 'dispatcher' unless defined?(::Dispatcher)
-::Dispatcher.class_eval do
-
- def self.prepare_application_for_dispatch
- if (self.private_methods.include? "prepare_application")
- prepare_application
- else
- disp = new(STDOUT)
- if disp.respond_to?(:prepare_application)
- disp.prepare_application
- elsif disp.respond_to?(:reload_application)
- disp.reload_application
- end
- end
- end
-
- def self.reset_application_after_dispatch
- if (self.private_methods.include? "reset_after_dispatch")
- reset_after_dispatch
- else
- disp = new(STDOUT)
- if disp.respond_to?(:cleanup_application)
- disp.cleanup_application
- end
- end
- end
-
-end
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/test_helper.rb b/vendor/plugins/activemessaging/lib/activemessaging/test_helper.rb
deleted file mode 100644
index 6248da0..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/test_helper.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-require 'test/unit'
-#require "#{File.dirname(__FILE__)}/trace_filter"
-
-
-module ActiveMessaging #:nodoc:
-
- # def self.reload_activemessaging
- # end
-
- class Gateway
-
- def self.reset
- unsubscribe
- disconnect
- @@filters = []
- @@subscriptions = {}
- @@named_destinations = {}
- @@processor_groups = {}
- @@current_processor_group = nil
- @@connections = {}
- end
- end
-
- module MessageSender
-
- @@__a13g_initialized__ = false
- def publish_with_reset(destination_name, message, headers={}, timeout=10)
- unless @@__a13g_initialized__
- ActiveMessaging.reload_activemessaging
- @@__a13g_initialized__ = true
- end
- publish_without_reset(destination_name, message, headers, timeout)
- end
-
- alias_method_chain :publish, :reset
-
- end
-
- class TestMessage
- attr_reader :headers
- attr_accessor :body
-
- def initialize(destination, headers = {}, body = "")
- @headers, @body = headers, body
- @headers['destination'] = destination
- end
-
- def command
- "MESSAGE"
- end
- end
-
- module TestHelper
-
- # #Many thanks must go to the ActiveRecord fixture code
- # #for showing how to properly alias setup and teardown
- # def self.included(base)
- # base.extend(ClassMethods)
- #
- # class << base
- # alias_method_chain :method_added, :a13g
- # end
- #
- # end
-
- # module ClassMethods
- #
- # def method_added_with_a13g(method)
- # return if @__a13g_disable_method_added__
- # @__a13g_disable_method_added__ = true
- #
- # case method.to_s
- # when 'setup'
- # unless method_defined?(:setup_without_a13g)
- # alias_method :setup_without_a13g, :setup
- # define_method(:full_setup) do
- # setup_with_a13g
- # setup_without_a13g
- # end
- # end
- # alias_method :setup, :full_setup
- # when 'teardown'
- # unless method_defined?(:teardown_without_a13g)
- # alias_method :teardown_without_a13g, :teardown
- # define_method(:full_teardown) do
- # teardown_without_a13g
- # teardown_with_a13g
- # end
- # end
- # alias_method :teardown, :full_teardown
- # end
- #
- # method_added_without_a13g(method)
- #
- # @__a13g_disable_method_added__ = false
- # end
- #
- # end
-
- # def setup_with_a13g
- # ActiveMessaging.reload_activemessaging
- # end
- #
- # def teardown_with_a13g
- # ActiveMessaging::Gateway.reset
- # end
-
- def mock_publish destination, body, publisher=nil, headers={}
- ActiveMessaging::Gateway.publish destination, body, publisher, headers
- end
-
- def assert_message destination, body
- destination = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- Message for '#{destination}' with '#{body}' is not present.
- Messages:
- #{ActiveMessaging::Gateway.connection('default').all_messages.inspect}
- EOF
- assert ActiveMessaging::Gateway.connection.find_message(destination, body), error_message
- end
-
- def assert_no_message_with destination, body
- destination = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- Message for '#{destination}' with '#{body}' is present.
- Messages:
- #{ActiveMessaging::Gateway.connection('default').all_messages.inspect}
- EOF
- assert_nil ActiveMessaging::Gateway.connection('default').find_message(destination, body), error_message
- end
-
- def assert_no_messages destination
- destination = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- Expected no messages.
- Messages:
- #{ActiveMessaging::Gateway.connection('default').all_messages.inspect}
- EOF
- assert_equal [], ActiveMessaging::Gateway.connection('default').all_messages, error_message
- end
-
- def assert_subscribed destination
- destination = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- Not subscribed to #{destination}.
- Subscriptions:
- #{ActiveMessaging::Gateway.connection('default').subscriptions.inspect}
- EOF
- assert ActiveMessaging::Gateway.connection('default').find_subscription(destination), error_message
- end
-
- def assert_not_subscribed destination
- destination = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- Subscribed to #{destination}.
- Subscriptions:
- #{ActiveMessaging::Gateway.connection('default').subscriptions.inspect}
- EOF
- assert_nil ActiveMessaging::Gateway.connection('default').find_subscription(destination), error_message
- end
-
- def assert_has_messages destination
- destination_name = ActiveMessaging::Gateway.find_destination(destination).value
- error_message = <<-EOF
- No messages for #{destination_name}.
- All messages:
- #{ActiveMessaging::Gateway.connection('default').all_messages.inspect}
- EOF
- destination = ActiveMessaging::Gateway.connection('default').find_destination destination_name
- assert !destination.nil? && !destination.messages.empty?, error_message
- end
- end
-end
-
diff --git a/vendor/plugins/activemessaging/lib/activemessaging/trace_filter.rb b/vendor/plugins/activemessaging/lib/activemessaging/trace_filter.rb
deleted file mode 100644
index 4021f28..0000000
--- a/vendor/plugins/activemessaging/lib/activemessaging/trace_filter.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-class TraceFilter< ActiveMessaging::Filter
- include ActiveMessaging::MessageSender
-
- def initialize(options)
- @queue = options[:queue]
- TraceFilter.publishes_to @queue
- end
-
- def process message, routing
-
- unless ( routing[:destination].name == @queue ) then
- puts "\nTrace: direction = #{routing[:direction]} publisher=#{routing[:publisher]} queue=#{routing[:destination].name} @queue=#{@queue}\n"
- if routing[:direction].to_sym==:outgoing then
- "trace from outgoing"
- publish @queue, "<sent>"+
- "<from>#{routing[:publisher]}</from>" +
- "<queue>#{routing[:destination].name}</queue>" +
- "<message>#{message.body}</message>" +
- "</sent>"
- end
- if routing[:direction].to_sym==:incoming then
- "trace from incoming"
- publish @queue, "<received>"+
- "<by>#{routing[:receiver]}</by>" +
- "<queue>#{routing[:destination].name}</queue>" +
- "<message>#{message.body}</message>" +
- "</received>"
- end
- end
-
- end
-
-end
-
diff --git a/vendor/plugins/activemessaging/messaging.rb.example b/vendor/plugins/activemessaging/messaging.rb.example
deleted file mode 100644
index 6e13368..0000000
--- a/vendor/plugins/activemessaging/messaging.rb.example
+++ /dev/null
@@ -1,5 +0,0 @@
-
-ActiveMessaging::Dispatcher.define do |s|
- s.queue :orders, '/queue/Orders'
- s.queue :completed, '/queue/CompletedItems'
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/poller.rb b/vendor/plugins/activemessaging/poller.rb
deleted file mode 100644
index 6093e36..0000000
--- a/vendor/plugins/activemessaging/poller.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-# Make sure stdout and stderr write out without delay for using with daemon like scripts
-STDOUT.sync = true; STDOUT.flush
-STDERR.sync = true; STDERR.flush
-
-# Load Rails
-RAILS_ROOT=File.expand_path(File.join(File.dirname(__FILE__), '..','..','..'))
-load File.join(RAILS_ROOT, 'config', 'environment.rb')
-
-# Load ActiveMessaging processors
-ActiveMessaging::load_processors
-
-# Start it up!
-ActiveMessaging::start
diff --git a/vendor/plugins/activemessaging/tasks/start_consumers.rake b/vendor/plugins/activemessaging/tasks/start_consumers.rake
deleted file mode 100644
index 5ec1946..0000000
--- a/vendor/plugins/activemessaging/tasks/start_consumers.rake
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace "activemessaging" do
-
- desc 'Run all consumers'
- task :start_consumers do
- load File.dirname(__FILE__) + '/../poller.rb'
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/test/all_tests.rb b/vendor/plugins/activemessaging/test/all_tests.rb
deleted file mode 100644
index f0608d4..0000000
--- a/vendor/plugins/activemessaging/test/all_tests.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'rubygems'
-require_gem 'coverage'
-
-require 'test/unit'
-
-require 'test/config_test'
-require 'test/filter_test'
-require 'test/tracer_test'
-require 'test/jms_test'
-require 'test/asqs_test'
diff --git a/vendor/plugins/activemessaging/test/asqs_test.rb b/vendor/plugins/activemessaging/test/asqs_test.rb
deleted file mode 100644
index aa9b3fe..0000000
--- a/vendor/plugins/activemessaging/test/asqs_test.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-class AsqsTest < Test::Unit::TestCase
-
- class FakeHTTPResponse
- attr_accessor :headers, :body
-
- def to_hash
- @headers
- end
-
- def kind_of? kind
- true
- end
- end
-
- ActiveMessaging::Adapters::AmazonSQS::Connection.class_eval do
- attr_accessor :test_response, :test_headers
-
- DEFAULT_RESPONSE = <<EOM
- <ListQueuesResponse xmlns='http://queue.amazonaws.com/doc/2007-05-01/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ListQueuesResponse'>
- <Queues>
- <QueueUrl>http://queue.amazonaws.com/thisisatestid1/test1</QueueUrl>
- <QueueUrl>http://queue.amazonaws.com/thisisatestid12/test2</QueueUrl>
- </Queues>
- <ResponseStatus><StatusCode>Success</StatusCode><RequestId>cb919c0a-9bce-4afe-9b48-9bdf2412bb67</RequestId></ResponseStatus>
- </ListQueuesResponse>
-EOM
-
- def http_request h, p, r
- raise test_response if test_response.is_a?(Exception)
-
- resp = FakeHTTPResponse.new
- resp.body = @test_response || DEFAULT_RESPONSE
- resp.headers = @test_headers || {}
- return resp
- end
- end
-
-
- def setup
- @connection = ActiveMessaging::Adapters::AmazonSQS::Connection.new(:reliable=>false, :access_key_id=>'access_key_id', :secret_access_key=>'secret_access_key', :reconnectDelay=>1)
- @d = "asqs"
- @message = "mary had a little lamb"
- end
-
- def teardown
- @connection.disconnect unless @connection.nil?
- end
-
- def test_allow_underscore_and_dash
- assert_nothing_raised do
- @connection.subscribe 'name-name_dash'
- end
- assert_raise(RuntimeError) do
- @connection.subscribe '!@#$%^&'
- end
- end
-
-
- def test_send_and_receive
- @connection.subscribe @d, :visibility_timeout=>100
- @connection.send @d, @message
-
- @connection.test_headers = {:destination=>@d}
- @connection.test_response = <<EOM
- <ReceiveMessageResponse>
- <Message>
- <MessageId>11YEJMCHE2DM483NGN40|3H4AA8J7EJKM0DQZR7E1|PT6DRTB278S4MNY77NJ0</MessageId>
- <ReceiptHandle>some handle value</ReceiptHandle>
- <Body>#{@message}</Body>
- <MD5OfBody>not really the md5</MD5OfBody>
- </Message>
- <ResponseStatus>
- <StatusCode>Success</StatusCode>
- <RequestId>b5bf2332-e983-4d3e-941a-f64c0d21f00f</RequestId>
- </ResponseStatus>
- </ReceiveMessageResponse>
-EOM
-
- message = @connection.receive
- assert_equal @message, message.body
- end
-
- def test_receive_timeout
- @connection.subscribe @d
- @connection.send @d, @message
-
- @connection.test_headers = {:destination=>@d}
- @connection.test_response = TimeoutError.new('test timeout error')
- @connection.reliable = true
- begin
- Timeout.timeout 2 do
- @connection.receive
- end
- rescue Timeout::Error=>toe
- assert_not_equal toe.message, 'test timeout error'
- end
- end
-
-end
diff --git a/vendor/plugins/activemessaging/test/config_test.rb b/vendor/plugins/activemessaging/test/config_test.rb
deleted file mode 100644
index 0e49cb9..0000000
--- a/vendor/plugins/activemessaging/test/config_test.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-class TestProcessor < ActiveMessaging::Processor
-end
-
-class ConfigTest < Test::Unit::TestCase
-
- def setup
- ActiveMessaging::Gateway.define do |s|
- s.destination :hello_world, '/queue/helloWorld'
- end
- end
-
- def teardown
- ActiveMessaging::Gateway.reset
- end
-
- def test_can_subscribe_to_named_queue
- TestProcessor.subscribes_to :hello_world
- sub = ActiveMessaging::Gateway.subscriptions.values.last
- assert_equal :hello_world, sub.destination.name
- assert_equal TestProcessor, sub.processor_class
- end
-
- def test_can_publish_to_named_queue
- TestProcessor.publishes_to :hello_world
- #no exception - publish just checks to see if the queue exists
- end
-
- def test_should_raise_error_if_subscribe_to_queue_that_does_not_exist
- assert_raises(RuntimeError) do
- TestProcessor.subscribes_to :queue_that_does_not_exist
- end
- end
-
- def test_should_raise_error_if_publishes_to_queue_that_does_not_exist
- assert_raises(RuntimeError) do
- TestProcessor.publishes_to :queue_that_does_not_exist
- end
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/test/filter_test.rb b/vendor/plugins/activemessaging/test/filter_test.rb
deleted file mode 100644
index 6985acc..0000000
--- a/vendor/plugins/activemessaging/test/filter_test.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-module ActiveMessaging #:nodoc:
- def self.reload_activemessaging
- end
-end
-
-class FilterTest < Test::Unit::TestCase
-
- class MockFilter < ActiveMessaging::Filter
-
- @@called = {}
- cattr_reader :called
-
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def process(message, details={})
- @@called[options[:name]] = {:message=>message, :details=>details}
- end
-
- class << self
- include Test::Unit::Assertions
-
- def reset
- @@called = {}
- end
-
- def assert_was_called(name=nil)
- assert @@called.has_key?(name)
- end
-
- def assert_was_not_called(name=nil)
- assert !@@called.has_key?(name)
- end
-
- def assert_routing(name, routing)
- assert_equal routing, @@called[name][:details]
- end
- end
- end
-
- class TestProcessor < ActiveMessaging::Processor
- include ActiveMessaging::MessageSender
- #subscribes_to :testqueue
-
- @@was_called = false
- class<<self
- include Test::Unit::Assertions
-
- def assert_was_called
- assert @@was_called
- @@was_called = false
- end
- end
-
- def on_message(message)
- @@was_called = true
- end
- end
-
- include ActiveMessaging::TestHelper
-
- def setup
- ActiveMessaging::Gateway.define do |d|
- d.destination :testqueue, '/queue/test.queue'
- d.filter 'filter_test/mock_filter', :direction=>:bidirectional, :name=>:bidirectional
- d.filter 'filter_test/mock_filter', :direction=>:incoming, :name=>:incoming
- d.filter 'filter_test/mock_filter', :direction=>:outgoing, :name=>:outgoing
-
- d.filter 'filter_test/mock_filter', :direction=>:incoming, :name=>:exclude_only, :only=>:foo
- d.filter 'filter_test/mock_filter', :direction=>:incoming, :name=>:include_only, :only=>:testqueue
- d.filter 'filter_test/mock_filter', :direction=>:incoming, :name=>:exclude_except, :except=>:testqueue
- d.filter 'filter_test/mock_filter', :direction=>:incoming, :name=>:include_except, :except=>:foo
- end
-
- TestProcessor.subscribes_to :testqueue
- MockFilter.reset
- end
-
- def teardown
- ActiveMessaging::Gateway.reset
- end
-
- def test_filters_use_include
- ActiveMessaging::Gateway.dispatch ActiveMessaging::TestMessage.new('/queue/test.queue')
- MockFilter.assert_was_called(:include_only)
- MockFilter.assert_was_not_called(:exclude_only)
- end
-
- def test_filters_use_exclude
- ActiveMessaging::Gateway.dispatch ActiveMessaging::TestMessage.new('/queue/test.queue')
- MockFilter.assert_was_called(:include_except)
- MockFilter.assert_was_not_called(:exclude_except)
- end
-
- def test_filters_and_processor_gets_called_on_receive
- ActiveMessaging::Gateway.dispatch ActiveMessaging::TestMessage.new('/queue/test.queue')
- MockFilter.assert_was_called(:bidirectional)
- MockFilter.assert_was_called(:incoming)
- MockFilter.assert_was_not_called(:outgoing)
- TestProcessor.assert_was_called
- end
-
- def test_filters_gets_called_on_publish
- ActiveMessaging::Gateway.publish :testqueue, "blah blah"
- MockFilter.assert_was_called(:bidirectional)
- MockFilter.assert_was_not_called(:incoming)
- MockFilter.assert_was_called(:outgoing)
- end
-
- def test_sets_routing_details_on_send
- sender = TestProcessor.new
- sender.publish :testqueue, "Hi there!"
-
- MockFilter.assert_was_called(:outgoing)
- MockFilter.assert_routing(:outgoing, {:destination=>ActiveMessaging::Gateway.find_queue(:testqueue), :publisher=>FilterTest::TestProcessor, :direction=>:outgoing})
- end
-
- def test_sets_routing_details_on_receive
- ActiveMessaging::Gateway.dispatch ActiveMessaging::TestMessage.new('/queue/test.queue')
-
- MockFilter.assert_was_called(:incoming)
- MockFilter.assert_routing(:incoming, {:destination=>ActiveMessaging::Gateway.find_queue(:testqueue), :receiver=>FilterTest::TestProcessor, :direction=>:incoming})
- end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/test/gateway_test.rb b/vendor/plugins/activemessaging/test/gateway_test.rb
deleted file mode 100644
index 5d96e48..0000000
--- a/vendor/plugins/activemessaging/test/gateway_test.rb
+++ /dev/null
@@ -1,195 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-class InitializeFilter
-
- attr_accessor :options
-
- def initialize(options)
- @options = options
- end
-
- def process(message, details={})
- puts "ObjectFilter process called!"
- end
-end
-
-class GatewayTest < Test::Unit::TestCase
-
-
- class ClassFilter
-
- def initialize
- raise "Don't try and construct one of these please"
- end
-
- class << self
- def process(message, details={})
- puts "ClassFilter process called!"
- end
- end
- end
-
- class ObjectFilter
- def process(message, details={})
- puts "ObjectFilter process called!"
- end
- end
-
- class TestProcessor < ActiveMessaging::Processor
- include ActiveMessaging::MessageSender
- #subscribes_to :testqueue
- def on_message(message)
- @test_message = true
- end
- end
-
- class TestRetryProcessor < ActiveMessaging::Processor
- include ActiveMessaging::MessageSender
- #subscribes_to :testqueue
- def on_message(message)
- puts "TestRetryProcessor - about to raise exception"
- raise ActiveMessaging::AbortMessageException.new("Cause a retry!")
- end
- end
-
- class TestAdapter
- end
-
- def setup
- end
-
- def teardown
- ActiveMessaging::Gateway.reset
- end
-
-
- def test_create_filter
- filter_obj = ActiveMessaging::Gateway.create_filter('gateway_test/object_filter', {:direction=>:incoming, :name=>'test1'})
- assert filter_obj
- assert filter_obj.is_a?(GatewayTest::ObjectFilter)
-
- filter_obj = ActiveMessaging::Gateway.create_filter('initialize_filter', {:direction=>:incoming, :name=>'test2'})
- assert filter_obj
- assert filter_obj.is_a?(InitializeFilter)
- assert_equal filter_obj.options, {:direction=>:incoming, :name=>'test2'}
-
- filter_obj = ActiveMessaging::Gateway.create_filter(:initialize_filter, {:direction=>:incoming, :name=>'test2'})
- assert filter_obj
- assert filter_obj.is_a?(InitializeFilter)
- assert_equal filter_obj.options, {:direction=>:incoming, :name=>'test2'}
-
- filter_obj = ActiveMessaging::Gateway.create_filter(:'gateway_test/class_filter', {:direction=>:incoming, :name=>'test2'})
- assert filter_obj
- assert filter_obj.is_a?(Class)
- assert_equal filter_obj.name, "GatewayTest::ClassFilter"
- end
-
- def test_register_adapter
- ActiveMessaging::Gateway.register_adapter :test_register_adapter, TestAdapter
- assert_equal TestAdapter, ActiveMessaging::Gateway.adapters[:test_register_adapter]
- end
-
- def test_destination
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- dest = ActiveMessaging::Gateway.named_destinations[:hello_world]
- assert_equal :hello_world, dest.name
- end
-
- def test_destination_duplicates
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- dest = ActiveMessaging::Gateway.named_destinations[:hello_world]
- assert_equal :hello_world, dest.name
-
- # make sure a dupe name causes an error
- assert_raises RuntimeError do
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld2'
- end
- end
-
- def test_connection
- conn = ActiveMessaging::Gateway.connection
- assert_equal conn.class, ActiveMessaging::Adapters::Test::Connection
- end
-
- def test_subscribe_and_unsubscribe
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- ActiveMessaging::Gateway.subscribe_to :hello_world, TestProcessor, headers={}
- sub = ActiveMessaging::Gateway.subscriptions.values.last
- assert_equal :hello_world, sub.destination.name
- assert_equal TestProcessor, sub.processor_class
-
- ActiveMessaging::Gateway.subscribe
- assert_not_nil ActiveMessaging::Gateway.connection.find_subscription(sub.destination.value)
-
- ActiveMessaging::Gateway.unsubscribe
- assert_nil ActiveMessaging::Gateway.connection.find_subscription(sub.destination.value)
- end
-
- def test_disconnect
- assert_equal 0, ActiveMessaging::Gateway.connections.keys.size
-
- conn = ActiveMessaging::Gateway.connection
- assert_equal 1, ActiveMessaging::Gateway.connections.keys.size
- assert_equal true, conn.connected
-
- ActiveMessaging::Gateway.disconnect
-
- assert_equal 0, ActiveMessaging::Gateway.connections.keys.size
- assert_equal false, conn.connected
- end
-
- def test_publish
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- ActiveMessaging::Gateway.publish :hello_world, "test_publish body", self.class, headers={}, timeout=10
- assert_not_nil ActiveMessaging::Gateway.connection.find_message('/queue/helloWorld', "test_publish body")
-
- assert_raise(RuntimeError) do
- ActiveMessaging::Gateway.publish :hello_world, nil, self.class, headers={}, timeout=10
- end
- assert_raise(RuntimeError) do
- ActiveMessaging::Gateway.publish :hello_world, '', self.class, headers={}, timeout=10
- end
- end
-
- def test_acknowledge_message
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- ActiveMessaging::Gateway.subscribe_to :hello_world, TestProcessor, headers={}
- sub = ActiveMessaging::Gateway.subscriptions.values.last
- dest = ActiveMessaging::Adapters::Test::Destination.new '/queue/helloWorld'
- msg = ActiveMessaging::Adapters::Test::Message.new({}, nil, "message_body", nil, dest)
- ActiveMessaging::Gateway.acknowledge_message sub, msg
- assert_equal msg, ActiveMessaging::Gateway.connection.received_messages.first
- end
-
- def test_abort_message
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- ActiveMessaging::Gateway.subscribe_to :hello_world, TestRetryProcessor, headers={}
- sub = ActiveMessaging::Gateway.subscriptions.values.last
- dest = ActiveMessaging::Adapters::Test::Destination.new '/queue/helloWorld'
- msg = ActiveMessaging::Adapters::Test::Message.new({}, nil, "message_body", nil, dest)
- ActiveMessaging::Gateway.dispatch(msg)
- assert_equal msg, ActiveMessaging::Gateway.connection.unreceived_messages.first
- end
-
- def test_receive
- ActiveMessaging::Gateway.destination :hello_world, '/queue/helloWorld'
- ActiveMessaging::Gateway.publish :hello_world, "test_publish body", self.class, headers={}, timeout=10
- msg = ActiveMessaging::Gateway.receive :hello_world, self.class, headers={}, timeout=10
- assert_not_nil ActiveMessaging::Gateway.connection.find_message('/queue/helloWorld', "test_publish body")
- end
-
- def test_reload
- ActiveMessaging.reload_activemessaging
- size = ActiveMessaging::Gateway.named_destinations.size
- ActiveMessaging.reload_activemessaging
- assert_equal size, ActiveMessaging::Gateway.named_destinations.size
- end
-
- ## figure out how to test these better - start in a thread perhaps?
- # def test_start
- # end
- #
- # def test_stop
- # end
-
-end
diff --git a/vendor/plugins/activemessaging/test/jms_test.rb b/vendor/plugins/activemessaging/test/jms_test.rb
deleted file mode 100644
index c357c4f..0000000
--- a/vendor/plugins/activemessaging/test/jms_test.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-if defined?(JRUBY_VERSION)
-
-class JmsTest < Test::Unit::TestCase
-
- def setup
- @test_txt = 'Yo Homie!'
- @isolation_const = rand(99999999)
- @connection = ActiveMessaging::Adapters::Jms::Connection.new(:url => 'tcp://localhost:61616',
- :login => '',
- :passcode => '',
- :connection_factory => 'org.apache.activemq.ActiveMQConnectionFactory')
- end
-
- def test_send
- @connection.send "/queue/TestQueue#{@isolation_const}", @test_txt, {}
- end
-
- def test_receive_with_one
- @connection.send "/queue/TestQueue#{@isolation_const}", @test_txt
- @connection.subscribe "/queue/TestQueue#{@isolation_const}"
- message = @connection.receive
- assert_equal @test_txt, message.body
- end
-
- def test_receive_multi
- 10.times do |i|
- @connection.send "/queue/MultiQueue#{@isolation_const}", @test_txt
- end
-
- counter=0
- @connection.subscribe "/queue/MultiQueue#{@isolation_const}"
- while message = @connection.receive
- assert_equal @test_txt, message.body
- counter += 1
- end
- assert_equal 10, counter
- end
-
- def test_one_off_receive
- @connection.send "/queue/OneOff#{@isolation_const}", "one off message"
- message = @connection.receive "/queue/OneOff#{@isolation_const}"
- assert_equal "one off message", message.body
- assert_equal "MESSAGE", message.command
- assert_equal "/queue/OneOff#{@isolation_const}", message.headers['destination']
- end
-
- def test_unsubscribe
- @connection.subscribe "/queue/TestSubQueue#{@isolation_const}"
- @connection.unsubscribe "/queue/TestSubQueue#{@isolation_const}"
- assert_nil @connection.consumers["TestSubQueue#{@isolation_const}"]
- end
-
- def teardown
- @connection.close unless @connection.nil?
- end
-
-end
-
-end \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/test/reliable_msg_test.rb b/vendor/plugins/activemessaging/test/reliable_msg_test.rb
deleted file mode 100644
index c016b96..0000000
--- a/vendor/plugins/activemessaging/test/reliable_msg_test.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-loaded = true
-begin
- require 'reliable-msg'
-rescue Object => e
- loaded = false
-end
-if loaded
-
-class ReliableMsgTest < Test::Unit::TestCase
-
- def setup
- @qm = ReliableMsg::QueueManager.new
- @qm.start
- @connection = ActiveMessaging::Adapters::ReliableMsg::Connection.new(:reliable=>false, :poll_interval=>2)
- @d = "/queue/reliable.msg.test}."
- @message = "mary had a little lamb"
- @message2 = "whose fleece was white as snow"
- end
-
- def teardown
- @connection.disconnect unless @connection.nil?
- @qm.stop unless @qm.nil?
- end
-
- def test_subscribe_and_unsubscribe
- assert_nil @connection.subscriptions["#{@d}test_subscribe"]
- @connection.subscribe "#{@d}test_subscribe"
- assert_equal 1, @connection.subscriptions["#{@d}test_subscribe"].count
- @connection.subscribe "#{@d}test_subscribe"
- assert_equal 2, @connection.subscriptions["#{@d}test_subscribe"].count
- @connection.unsubscribe "#{@d}test_subscribe"
- assert_equal 1, @connection.subscriptions["#{@d}test_subscribe"].count
- @connection.unsubscribe "#{@d}test_subscribe"
- assert_nil @connection.subscriptions["#{@d}test_subscribe"]
- end
-
- def test_send_and_receive
- @connection.subscribe "#{@d}test_send_and_receive"
- @connection.send "#{@d}test_send_and_receive", @message
- message = @connection.receive
- @connection.received message
- assert_equal @message, message.body
- end
-
-
- def test_send_and_receive_multiple_subscriptions
- @connection.subscribe "#{@d}test_send_and_receive1"
- @connection.subscribe "#{@d}test_send_and_receive2"
- @connection.subscribe "#{@d}test_send_and_receive3"
-
- @connection.send "#{@d}test_send_and_receive2", "message2"
- message = @connection.receive
- @connection.received message
- assert_equal "message2", message.body
-
- @connection.send "#{@d}test_send_and_receive3", "message3"
- message = @connection.receive
- @connection.received message
- assert_equal "message3", message.body
-
- end
-
-
- def test_will_cause_sleep
-
- begin
- Timeout.timeout 10 do
- @connection.subscribe "#{@d}test_will_cause_sleep"
- message = @connection.receive
- @connection.received message
- assert false
- end
- rescue Timeout::Error=>toe
- assert true
- end
- end
-
-end
-
-end # if loaded \ No newline at end of file
diff --git a/vendor/plugins/activemessaging/test/test_helper.rb b/vendor/plugins/activemessaging/test/test_helper.rb
deleted file mode 100644
index c59d77d..0000000
--- a/vendor/plugins/activemessaging/test/test_helper.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# load the rails environment
-# TODO currently requires you to run tests as a installed plugin, we should try to fix this
-ENV['RAILS_ENV'] = "test"
-require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
-
-# load other libraries
-require 'test/unit'
-
-# load activemessaging
-# TODO this is already loaded automatically by starting Rails
-# but we may need to do this if we want to run a13g tests without Rails
-#require File.dirname(__FILE__) + '/../lib/activemessaging/processor'
-#require File.dirname(__FILE__) + '/../lib/activemessaging/gateway'
-require File.dirname(__FILE__) + '/../lib/activemessaging/test_helper'
-
-
diff --git a/vendor/plugins/activemessaging/test/tracer_test.rb b/vendor/plugins/activemessaging/test/tracer_test.rb
deleted file mode 100644
index 5ec87f1..0000000
--- a/vendor/plugins/activemessaging/test/tracer_test.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper'
-
-module ActiveMessaging #:nodoc:
- def self.reload_activemessaging
- end
-end
-
-class TestProcessor < ActiveMessaging::Processor
- #subscribes_to :hello_world
-
- def on_message message
- #do nothing
- end
-end
-
-class TestSender < ActiveMessaging::Processor
- #publishes_to :hello_world
-
-end
-
-class FakeMessage
- def command
- 'MESSAGE'
- end
- def headers
- {'destination'=>'/queue/helloWorld'}
- end
- def body
- "Ni hao ma?"
- end
-end
-
-class TracerTest < Test::Unit::TestCase
- include ActiveMessaging::TestHelper
- def setup
- ActiveMessaging::Gateway.define do |s|
- s.queue :hello_world, '/queue/helloWorld'
- s.queue :trace, '/queue/trace'
-
- s.filter :trace_filter, :queue=>:trace
- end
-
- TestProcessor.subscribes_to :hello_world
- TestSender.publishes_to :hello_world
- end
-
- def teardown
- ActiveMessaging::Gateway.reset
- end
-
- def test_should_trace_sent_messages
- message = "Ni hao ma?"
-
- sender = TestSender.new
- sender.publish :hello_world, message
-
- assert_message :trace, "<sent><from>TestSender</from><queue>hello_world</queue><message>#{message}</message></sent>"
- assert_message :hello_world, message
- end
-
- def test_should_trace_received_messages
- message = "Ni hao ma?"
-
- ActiveMessaging::Gateway.dispatch FakeMessage.new
-
- assert_message :trace, "<received><by>TestProcessor</by><queue>hello_world</queue><message>#{message}</message></received>"
- end
-end \ No newline at end of file