eventbus 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- metadata +25 -122
- data/admin/Gemfile +0 -50
- data/admin/Gemfile.lock +0 -141
- data/admin/Rakefile +0 -7
- data/admin/app/assets/images/rails.png +0 -0
- data/admin/app/assets/javascripts/application.js +0 -15
- data/admin/app/assets/javascripts/applications.js.coffee +0 -3
- data/admin/app/assets/javascripts/message_routes.js.coffee +0 -3
- data/admin/app/assets/javascripts/message_types.js.coffee +0 -3
- data/admin/app/assets/javascripts/messages.js.coffee +0 -3
- data/admin/app/assets/stylesheets/application.css +0 -13
- data/admin/app/assets/stylesheets/applications.css.scss +0 -3
- data/admin/app/assets/stylesheets/global.css.scss +0 -72
- data/admin/app/assets/stylesheets/message_routes.css.scss +0 -3
- data/admin/app/assets/stylesheets/message_types.css.scss +0 -3
- data/admin/app/assets/stylesheets/messages.css.scss +0 -30
- data/admin/app/assets/stylesheets/scaffolds.css.scss +0 -56
- data/admin/app/controllers/application_controller.rb +0 -3
- data/admin/app/controllers/applications_controller.rb +0 -83
- data/admin/app/controllers/message_routes_controller.rb +0 -85
- data/admin/app/controllers/message_types_controller.rb +0 -83
- data/admin/app/controllers/messages_controller.rb +0 -75
- data/admin/app/helpers/application_helper.rb +0 -2
- data/admin/app/helpers/applications_helper.rb +0 -2
- data/admin/app/helpers/message_routes_helper.rb +0 -2
- data/admin/app/helpers/message_types_helper.rb +0 -2
- data/admin/app/helpers/messages_helper.rb +0 -2
- data/admin/app/models/application.rb +0 -7
- data/admin/app/models/message.rb +0 -4
- data/admin/app/models/message_route.rb +0 -5
- data/admin/app/models/message_type.rb +0 -7
- data/admin/app/views/applications/_form.html.haml +0 -27
- data/admin/app/views/applications/edit.html.haml +0 -5
- data/admin/app/views/applications/index.html.haml +0 -28
- data/admin/app/views/applications/new.html.haml +0 -3
- data/admin/app/views/applications/show.html.haml +0 -16
- data/admin/app/views/layouts/application.html.haml +0 -24
- data/admin/app/views/message_routes/_form.html.haml +0 -31
- data/admin/app/views/message_routes/edit.html.haml +0 -5
- data/admin/app/views/message_routes/index.html.haml +0 -28
- data/admin/app/views/message_routes/new.html.haml +0 -3
- data/admin/app/views/message_routes/show.html.haml +0 -16
- data/admin/app/views/message_types/_form.html.haml +0 -29
- data/admin/app/views/message_types/edit.html.haml +0 -5
- data/admin/app/views/message_types/index.html.haml +0 -28
- data/admin/app/views/message_types/new.html.haml +0 -5
- data/admin/app/views/message_types/show.html.haml +0 -17
- data/admin/app/views/messages/index.html.haml +0 -48
- data/admin/app/views/messages/show.html.haml +0 -45
- data/admin/config/application.rb +0 -64
- data/admin/config/boot.rb +0 -6
- data/admin/config/database.yml +0 -29
- data/admin/config/environment.rb +0 -5
- data/admin/config/environments/development.rb +0 -37
- data/admin/config/environments/production.rb +0 -72
- data/admin/config/environments/test.rb +0 -37
- data/admin/config/initializers/backtrace_silencers.rb +0 -7
- data/admin/config/initializers/inflections.rb +0 -15
- data/admin/config/initializers/mime_types.rb +0 -5
- data/admin/config/initializers/secret_token.rb +0 -7
- data/admin/config/initializers/session_store.rb +0 -8
- data/admin/config/initializers/wrap_parameters.rb +0 -14
- data/admin/config/locales/en.yml +0 -5
- data/admin/config/routes.rb +0 -69
- data/admin/config.ru +0 -4
- data/admin/db/development.sqlite3-journal +0 -0
- data/admin/db/migrate/20120218124300_create_messages.rb +0 -16
- data/admin/db/migrate/20120219021535_create_applications.rb +0 -11
- data/admin/db/migrate/20120219021806_create_message_types.rb +0 -13
- data/admin/db/migrate/20120219021940_create_message_routes.rb +0 -13
- data/admin/db/migrate/20120411001040_add_app_id_key_msg_type_id_to_messages.rb +0 -7
- data/admin/db/migrate/20120411001823_rename_message_type_to_message_type_name_in_messages.rb +0 -5
- data/admin/db/migrate/20120413024953_add_message_guid_to_messages.rb +0 -5
- data/admin/db/migrate/20120523112257_add_match_all_errors_to_routes.rb +0 -5
- data/admin/db/schema.rb +0 -68
- data/admin/db/seeds.rb +0 -7
- data/admin/doc/README_FOR_APP +0 -2
- data/admin/public/404.html +0 -26
- data/admin/public/422.html +0 -26
- data/admin/public/500.html +0 -25
- data/admin/public/favicon.ico +0 -0
- data/admin/public/robots.txt +0 -5
- data/admin/script/rails +0 -6
- data/admin/script/railsrunner +0 -3
- data/admin/test/fixtures/applications.yml +0 -14
- data/admin/test/fixtures/message_routes.yml +0 -11
- data/admin/test/fixtures/message_types.yml +0 -17
- data/admin/test/fixtures/messages.yml +0 -45
- data/admin/test/functional/applications_controller_test.rb +0 -49
- data/admin/test/functional/message_routes_controller_test.rb +0 -49
- data/admin/test/functional/message_types_controller_test.rb +0 -49
- data/admin/test/functional/messages_controller_test.rb +0 -49
- data/admin/test/performance/browsing_test.rb +0 -12
- data/admin/test/test_helper.rb +0 -13
- data/admin/test/unit/application_test.rb +0 -7
- data/admin/test/unit/helpers/applications_helper_test.rb +0 -4
- data/admin/test/unit/helpers/message_routes_helper_test.rb +0 -4
- data/admin/test/unit/helpers/message_types_helper_test.rb +0 -4
- data/admin/test/unit/helpers/messages_helper_test.rb +0 -4
- data/admin/test/unit/message_route_test.rb +0 -7
- data/admin/test/unit/message_test.rb +0 -7
- data/admin/test/unit/message_type_test.rb +0 -7
- data/bin/eventbus_dispatcher.rb +0 -118
- data/bin/eventbus_emailer.rb +0 -41
- data/lib/eventbus/connectors/amqp.rb +0 -70
- data/lib/eventbus/connectors/bunny.rb +0 -71
- data/lib/eventbus/connectors/stomp.rb +0 -77
@@ -1,70 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'amqp'
|
3
|
-
|
4
|
-
module AMQPConnectionDriver
|
5
|
-
|
6
|
-
|
7
|
-
def connection_driver_initialize
|
8
|
-
puts "AMQPConnectionDriver is loaded!"
|
9
|
-
end
|
10
|
-
|
11
|
-
def get_connection
|
12
|
-
new_opts = {
|
13
|
-
:vhost => ENV["BROKER_VHOST"] || "eventbus",
|
14
|
-
:host => ENV["BROKER_HOST"] || "localhost",
|
15
|
-
:port => ENV["BROKER_PORT"] || 5672,
|
16
|
-
:user => ENV["BROKER_USER"] || "eventbus",
|
17
|
-
:pass => ENV["BROKER_PASS"] || "eventbus",
|
18
|
-
# :logging => opts.delete(:logging) || false,
|
19
|
-
#:logfile => opts.delete(:logfile) || STDOUT
|
20
|
-
}
|
21
|
-
|
22
|
-
return AMQP.connect(new_opts)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def send_raw(content, opts = {})
|
27
|
-
queue_name = opts.delete(:queue_name)
|
28
|
-
EventMachine.run do
|
29
|
-
client = get_connection
|
30
|
-
channel = AMQP::Channel.new(client)
|
31
|
-
|
32
|
-
exchange = channel.direct('eventbus', :durable => true,
|
33
|
-
:persistent => true, :immediate => false,
|
34
|
-
:auto_delete => false)
|
35
|
-
|
36
|
-
puts "Declaring queue: #{queue_name}"
|
37
|
-
q = channel.queue(queue_name, :durable => true, :persistent => true, :immediate => false, :auto_delete => false)
|
38
|
-
q.bind(exchange, :routing_key => queue_name)
|
39
|
-
|
40
|
-
puts "Sending message..."
|
41
|
-
exchange.publish(content, :routing_key => queue_name) do
|
42
|
-
puts "Published to #{queue_name}: #{content}"
|
43
|
-
client.close { EventMachine.stop }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def watch_queue(listen_queue)
|
49
|
-
EventMachine.run do
|
50
|
-
client = get_connection
|
51
|
-
channel = AMQP::Channel.new(client)
|
52
|
-
|
53
|
-
@logger.info "Listening on #{listen_queue}"
|
54
|
-
|
55
|
-
exchange = channel.direct('eventbus', :durable => true,
|
56
|
-
:persistent => true, :immediate => false,
|
57
|
-
:auto_delete => false)
|
58
|
-
|
59
|
-
q = channel.queue(listen_queue, :durable => true, :persistent => true, :immediate => false, :auto_delete => false)
|
60
|
-
|
61
|
-
|
62
|
-
q.bind(exchange, :routing_key => listen_queue)
|
63
|
-
|
64
|
-
q.subscribe do |headers, payload|
|
65
|
-
yield payload
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# BunnyConnectionDriver is the original implementation of
|
2
|
-
# the AMQP-based broker. I am trying to make this work with
|
3
|
-
# straight Ruby AMQP driver, but this one is the default
|
4
|
-
# until I get that working properly.
|
5
|
-
|
6
|
-
module BunnyConnectionDriver
|
7
|
-
|
8
|
-
@@BunnyConnector_Connection = nil
|
9
|
-
|
10
|
-
def connection_driver_initialize
|
11
|
-
puts "BunnyConnectionDriver is loaded!"
|
12
|
-
end
|
13
|
-
|
14
|
-
def get_connection
|
15
|
-
if @@BunnyConnector_Connection.nil?
|
16
|
-
new_opts = {
|
17
|
-
:vhost => ENV["BROKER_VHOST"] || "eventbus",
|
18
|
-
:host => ENV["BROKER_HOST"] || "localhost",
|
19
|
-
:port => ENV["BROKER_PORT"] || 5672,
|
20
|
-
:user => ENV["BROKER_USER"] || "eventbus",
|
21
|
-
:pass => ENV["BROKER_PASS"] || "eventbus",
|
22
|
-
# :logging => opts.delete(:logging) || false,
|
23
|
-
#:logfile => opts.delete(:logfile) || STDOUT
|
24
|
-
}
|
25
|
-
|
26
|
-
@@BunnyConnector_Connection = Bunny.new(new_opts)
|
27
|
-
@@BunnyConnector_Connection.start
|
28
|
-
end
|
29
|
-
|
30
|
-
return @@BunnyConnector_Connection
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def send_raw(content, opts = {})
|
35
|
-
queue_name = opts.delete(:queue_name)
|
36
|
-
client = get_connection
|
37
|
-
|
38
|
-
exchange = client.exchange('eventbus', :durable => true, :persistent => true, :immediate => false)
|
39
|
-
|
40
|
-
puts "Declaring queue: #{queue_name}"
|
41
|
-
q = client.queue(queue_name, :durable => true, :persistent => true, :immediate => false)
|
42
|
-
q.bind('eventbus', :key => queue_name)
|
43
|
-
|
44
|
-
puts "Publishing content to #{queue_name}: #{content}"
|
45
|
-
exchange.publish(content, :key => queue_name)
|
46
|
-
puts "Done!"
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def watch_queue(listen_queue)
|
51
|
-
|
52
|
-
b = get_connection
|
53
|
-
|
54
|
-
@logger.info "Listening on #{listen_queue}"
|
55
|
-
|
56
|
-
exchange = b.exchange('eventbus', :durable => true, :persistent => true, :immediate => false)
|
57
|
-
|
58
|
-
q = b.queue(listen_queue, :durable => true, :persistent => true, :immediate => false)
|
59
|
-
q.bind(exchange, :key => listen_queue)
|
60
|
-
|
61
|
-
q.pop do |msg|
|
62
|
-
if msg[:delivery_details].nil?
|
63
|
-
# Gotta figure out why this is necessary. Blech.
|
64
|
-
sleep 0.25
|
65
|
-
else
|
66
|
-
yield msg[:payload]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# This module is primarily intended for use with ActiveMQ, though
|
2
|
-
# it should work with any Stomp-speaking broker.
|
3
|
-
require 'stomp'
|
4
|
-
module StompConnectionDriver
|
5
|
-
|
6
|
-
@@StompConnector_Connection = nil
|
7
|
-
|
8
|
-
def connection_driver_initialize
|
9
|
-
puts "StompConnectionDriver is loaded!"
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_connection
|
13
|
-
if @@StompConnector_Connection.nil?
|
14
|
-
opts = {
|
15
|
-
:host => ENV["BROKER_HOST"] || "localhost",
|
16
|
-
:port => ENV["BROKER_PORT"] || 61613,
|
17
|
-
:user => ENV["BROKER_USER"],
|
18
|
-
:pass => ENV["BROKER_PASS"],
|
19
|
-
# :logging => opts.delete(:logging) || false,
|
20
|
-
#:logfile => opts.delete(:logfile) || STDOUT
|
21
|
-
}
|
22
|
-
|
23
|
-
stomp_url = ENV['STOMP_URL'] ||
|
24
|
-
"stomp://#{opts[:user]}:#{opts[:pass]}@#{opts[:host]}:#{opts[:port]}?initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false"
|
25
|
-
@@StompConnector_Connection = Stomp::Client.new(stomp_url)
|
26
|
-
end
|
27
|
-
|
28
|
-
return @@StompConnector_Connection
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
# opts basically just gets passed to the Stomp client.send, so it can be things
|
33
|
-
# like :persistent => false, etc. :persistent is true by default.
|
34
|
-
def send_raw(content, opts = {})
|
35
|
-
|
36
|
-
queue_name = opts.delete(:queue_name)
|
37
|
-
queue_name = "/queue/#{queue_name}"
|
38
|
-
|
39
|
-
opts[:persistent] = true if opts[:persistent].nil?
|
40
|
-
|
41
|
-
# "Fix" an ActiveMQ "bug" where it assumes that any message with a content-length
|
42
|
-
# header is a bytes-message instead of a text message. This behavior prevents the
|
43
|
-
# message conent from showing up in the "Message Details" section when you try
|
44
|
-
# to view the message in ActiveMQ's admin interface.
|
45
|
-
#
|
46
|
-
# Note that the *correct* behavior is the opposite of this: All Stomp messages
|
47
|
-
# are recommended to include content-length. However, this is the *less annoying*
|
48
|
-
# and *more useful* behavior.
|
49
|
-
opts[:suppress_content_length] = true if opts[:suppress_content_length].nil?
|
50
|
-
|
51
|
-
puts "Stomp sending message to: #{queue_name}"
|
52
|
-
|
53
|
-
client = get_connection
|
54
|
-
client.publish(queue_name, content, opts)
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def watch_queue(listen_queue)
|
59
|
-
client = get_connection
|
60
|
-
|
61
|
-
queue_name = listen_queue.match('^/') ? listen_queue : "/queue/#{listen_queue}"
|
62
|
-
|
63
|
-
# OK, so some assumption that we're using ActiveMQ here. We'll work that out eventually. The point
|
64
|
-
# is, though, that we want to allow for maximum parallelism -- not just by thread but also across
|
65
|
-
# processes and machines. Therefore, don't lock the queue exclusively (i.e. don't kill other clients!)
|
66
|
-
# and only take blocks of one message rather than claiming large blocks. These assumptions should become
|
67
|
-
# configurable at some point, but for now it's not really a concern.
|
68
|
-
puts "Subscribing to #{queue_name}..."
|
69
|
-
|
70
|
-
client.subscribe(queue_name, {"activemq.prefetchSize" => 1, "activemq.exclusive" => false}) do |msg|
|
71
|
-
yield msg.body
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|