eventbus 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. metadata +25 -122
  2. data/admin/Gemfile +0 -50
  3. data/admin/Gemfile.lock +0 -141
  4. data/admin/Rakefile +0 -7
  5. data/admin/app/assets/images/rails.png +0 -0
  6. data/admin/app/assets/javascripts/application.js +0 -15
  7. data/admin/app/assets/javascripts/applications.js.coffee +0 -3
  8. data/admin/app/assets/javascripts/message_routes.js.coffee +0 -3
  9. data/admin/app/assets/javascripts/message_types.js.coffee +0 -3
  10. data/admin/app/assets/javascripts/messages.js.coffee +0 -3
  11. data/admin/app/assets/stylesheets/application.css +0 -13
  12. data/admin/app/assets/stylesheets/applications.css.scss +0 -3
  13. data/admin/app/assets/stylesheets/global.css.scss +0 -72
  14. data/admin/app/assets/stylesheets/message_routes.css.scss +0 -3
  15. data/admin/app/assets/stylesheets/message_types.css.scss +0 -3
  16. data/admin/app/assets/stylesheets/messages.css.scss +0 -30
  17. data/admin/app/assets/stylesheets/scaffolds.css.scss +0 -56
  18. data/admin/app/controllers/application_controller.rb +0 -3
  19. data/admin/app/controllers/applications_controller.rb +0 -83
  20. data/admin/app/controllers/message_routes_controller.rb +0 -85
  21. data/admin/app/controllers/message_types_controller.rb +0 -83
  22. data/admin/app/controllers/messages_controller.rb +0 -75
  23. data/admin/app/helpers/application_helper.rb +0 -2
  24. data/admin/app/helpers/applications_helper.rb +0 -2
  25. data/admin/app/helpers/message_routes_helper.rb +0 -2
  26. data/admin/app/helpers/message_types_helper.rb +0 -2
  27. data/admin/app/helpers/messages_helper.rb +0 -2
  28. data/admin/app/models/application.rb +0 -7
  29. data/admin/app/models/message.rb +0 -4
  30. data/admin/app/models/message_route.rb +0 -5
  31. data/admin/app/models/message_type.rb +0 -7
  32. data/admin/app/views/applications/_form.html.haml +0 -27
  33. data/admin/app/views/applications/edit.html.haml +0 -5
  34. data/admin/app/views/applications/index.html.haml +0 -28
  35. data/admin/app/views/applications/new.html.haml +0 -3
  36. data/admin/app/views/applications/show.html.haml +0 -16
  37. data/admin/app/views/layouts/application.html.haml +0 -24
  38. data/admin/app/views/message_routes/_form.html.haml +0 -31
  39. data/admin/app/views/message_routes/edit.html.haml +0 -5
  40. data/admin/app/views/message_routes/index.html.haml +0 -28
  41. data/admin/app/views/message_routes/new.html.haml +0 -3
  42. data/admin/app/views/message_routes/show.html.haml +0 -16
  43. data/admin/app/views/message_types/_form.html.haml +0 -29
  44. data/admin/app/views/message_types/edit.html.haml +0 -5
  45. data/admin/app/views/message_types/index.html.haml +0 -28
  46. data/admin/app/views/message_types/new.html.haml +0 -5
  47. data/admin/app/views/message_types/show.html.haml +0 -17
  48. data/admin/app/views/messages/index.html.haml +0 -48
  49. data/admin/app/views/messages/show.html.haml +0 -45
  50. data/admin/config/application.rb +0 -64
  51. data/admin/config/boot.rb +0 -6
  52. data/admin/config/database.yml +0 -29
  53. data/admin/config/environment.rb +0 -5
  54. data/admin/config/environments/development.rb +0 -37
  55. data/admin/config/environments/production.rb +0 -72
  56. data/admin/config/environments/test.rb +0 -37
  57. data/admin/config/initializers/backtrace_silencers.rb +0 -7
  58. data/admin/config/initializers/inflections.rb +0 -15
  59. data/admin/config/initializers/mime_types.rb +0 -5
  60. data/admin/config/initializers/secret_token.rb +0 -7
  61. data/admin/config/initializers/session_store.rb +0 -8
  62. data/admin/config/initializers/wrap_parameters.rb +0 -14
  63. data/admin/config/locales/en.yml +0 -5
  64. data/admin/config/routes.rb +0 -69
  65. data/admin/config.ru +0 -4
  66. data/admin/db/development.sqlite3-journal +0 -0
  67. data/admin/db/migrate/20120218124300_create_messages.rb +0 -16
  68. data/admin/db/migrate/20120219021535_create_applications.rb +0 -11
  69. data/admin/db/migrate/20120219021806_create_message_types.rb +0 -13
  70. data/admin/db/migrate/20120219021940_create_message_routes.rb +0 -13
  71. data/admin/db/migrate/20120411001040_add_app_id_key_msg_type_id_to_messages.rb +0 -7
  72. data/admin/db/migrate/20120411001823_rename_message_type_to_message_type_name_in_messages.rb +0 -5
  73. data/admin/db/migrate/20120413024953_add_message_guid_to_messages.rb +0 -5
  74. data/admin/db/migrate/20120523112257_add_match_all_errors_to_routes.rb +0 -5
  75. data/admin/db/schema.rb +0 -68
  76. data/admin/db/seeds.rb +0 -7
  77. data/admin/doc/README_FOR_APP +0 -2
  78. data/admin/public/404.html +0 -26
  79. data/admin/public/422.html +0 -26
  80. data/admin/public/500.html +0 -25
  81. data/admin/public/favicon.ico +0 -0
  82. data/admin/public/robots.txt +0 -5
  83. data/admin/script/rails +0 -6
  84. data/admin/script/railsrunner +0 -3
  85. data/admin/test/fixtures/applications.yml +0 -14
  86. data/admin/test/fixtures/message_routes.yml +0 -11
  87. data/admin/test/fixtures/message_types.yml +0 -17
  88. data/admin/test/fixtures/messages.yml +0 -45
  89. data/admin/test/functional/applications_controller_test.rb +0 -49
  90. data/admin/test/functional/message_routes_controller_test.rb +0 -49
  91. data/admin/test/functional/message_types_controller_test.rb +0 -49
  92. data/admin/test/functional/messages_controller_test.rb +0 -49
  93. data/admin/test/performance/browsing_test.rb +0 -12
  94. data/admin/test/test_helper.rb +0 -13
  95. data/admin/test/unit/application_test.rb +0 -7
  96. data/admin/test/unit/helpers/applications_helper_test.rb +0 -4
  97. data/admin/test/unit/helpers/message_routes_helper_test.rb +0 -4
  98. data/admin/test/unit/helpers/message_types_helper_test.rb +0 -4
  99. data/admin/test/unit/helpers/messages_helper_test.rb +0 -4
  100. data/admin/test/unit/message_route_test.rb +0 -7
  101. data/admin/test/unit/message_test.rb +0 -7
  102. data/admin/test/unit/message_type_test.rb +0 -7
  103. data/bin/eventbus_dispatcher.rb +0 -118
  104. data/bin/eventbus_emailer.rb +0 -41
  105. data/lib/eventbus/connectors/amqp.rb +0 -70
  106. data/lib/eventbus/connectors/bunny.rb +0 -71
  107. data/lib/eventbus/connectors/stomp.rb +0 -77
data/admin/db/seeds.rb DELETED
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -1,2 +0,0 @@
1
- Use this README file to introduce your application and point to useful places in the API for learning more.
2
- Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
data/admin/script/rails DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- /usr/bin/env ruby $(dirname __FILE__)/rails runner $*
@@ -1,14 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- --- !omap
4
- TEST:
5
- name: Test Application
6
- key: TEST
7
- description: Test application for built-in smoke-test utilities
8
-
9
- SAMPLE:
10
- name: Sample Application
11
- key: SAMPLE
12
- description: Sample application with more complex routing
13
-
14
-
@@ -1,11 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- TestBegin:
4
- message_type: RouteTest
5
- incoming_status: BEGIN
6
- dispatch_to: receiver
7
-
8
- TestMessageReceived:
9
- message_type: RouteTest
10
- incoming_status: MESSAGE_RECEIVED
11
- dispatch_to: accounting
@@ -1,17 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- --- !omap
4
- RouteTest:
5
- application: TEST
6
- name: RouteTest
7
- description: Message for use by the bin/util programs
8
-
9
- Sample:
10
- application: SAMPLE
11
- name: Sample
12
- description: Sample message type
13
-
14
- AnotherSample:
15
- application: SAMPLE
16
- name: AnotherSample
17
- description: Second message type for Sample application
@@ -1,45 +0,0 @@
1
-
2
- RTBeginDTReceiver:
3
- message_type: RouteTest
4
- message_type_name: "RouteTest"
5
- application: TEST
6
- application_key: TEST
7
- is_error: false
8
- content: "---\n:HEADER:\n :message_id: 123f9b20-65ad-012f-1530-001cc094df04\n :message_type: RouteTest\n :status: BEGIN\n :application_id: TEST\n:ERROR_INFO:\n :is_error: false\n :backtrace: \n :message: \n:PAYLOAD:\n TestMessage:\n some_number: 12345\n some_text: abcdefg\n"
9
- status: BEGIN
10
- dispatch_to: receiver
11
- message_guid: 123f9b20-65ad-012f-1530-001cc094df04
12
-
13
- RTMsgReceivdDTAccounting:
14
- message_type: RouteTest
15
- message_type_name: "RouteTest"
16
- application: TEST
17
- application_key: TEST
18
- is_error: false
19
- content: "---\n:HEADER:\n :message_id: 123f9b20-65ad-012f-1530-001cc094df04\n :message_type: RouteTest\n :status: MESSAGE_RECEIVED\n :application_id: TEST\n:ERROR_INFO:\n :is_error: false\n :backtrace: \n :message: \n:PAYLOAD:\n TestMessage:\n some_number: 12345\n some_text: abcdefg\n"
20
- status: MESSAGE_RECEIVED
21
- dispatch_to: accounting
22
- message_guid: 123f9b20-65ad-012f-1530-001cc094df04
23
-
24
-
25
- RTBeginDTReceiver2:
26
- message_type: RouteTest
27
- message_type_name: "RouteTest"
28
- application: TEST
29
- application_key: TEST
30
- is_error: false
31
- content: "---\n:HEADER:\n :message_id: 9891a6d6-30b1-4392-ac1c-e6fba4cba74a\n :message_type: RouteTest\n :status: BEGIN\n :application_id: TEST\n:ERROR_INFO:\n :is_error: false\n :backtrace: \n :message: \n:PAYLOAD:\n TestMessage:\n some_number: 7890\n some_text: hijklmno\n"
32
- status: BEGIN
33
- dispatch_to: receiver
34
- message_guid: 9891a6d6-30b1-4392-ac1c-e6fba4cba74a
35
-
36
- RTMsgReceivdDTAccounting2:
37
- message_type: RouteTest
38
- message_type_name: "RouteTest"
39
- application: TEST
40
- application_key: TEST
41
- is_error: false
42
- content: "---\n:HEADER:\n :message_id: 9891a6d6-30b1-4392-ac1c-e6fba4cba74a\n :message_type: RouteTest\n :status: MESSAGE_RECEIVED\n :application_id: TEST\n:ERROR_INFO:\n :is_error: false\n :backtrace: \n :message: \n:PAYLOAD:\n TestMessage:\n some_number: 7890\n some_text: hijklmno\n"
43
- status: MESSAGE_RECEIVED
44
- dispatch_to: accounting
45
- message_guid: 9891a6d6-30b1-4392-ac1c-e6fba4cba74a
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ApplicationsControllerTest < ActionController::TestCase
4
- setup do
5
- @application = applications(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:applications)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create application" do
20
- assert_difference('Application.count') do
21
- post :create, application: @application.attributes
22
- end
23
-
24
- assert_redirected_to application_path(assigns(:application))
25
- end
26
-
27
- test "should show application" do
28
- get :show, id: @application
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @application
34
- assert_response :success
35
- end
36
-
37
- test "should update application" do
38
- put :update, id: @application, application: @application.attributes
39
- assert_redirected_to application_path(assigns(:application))
40
- end
41
-
42
- test "should destroy application" do
43
- assert_difference('Application.count', -1) do
44
- delete :destroy, id: @application
45
- end
46
-
47
- assert_redirected_to applications_path
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageRoutesControllerTest < ActionController::TestCase
4
- setup do
5
- @message_route = message_routes(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:message_routes)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create message_route" do
20
- assert_difference('MessageRoute.count') do
21
- post :create, message_route: @message_route.attributes
22
- end
23
-
24
- assert_redirected_to message_route_path(assigns(:message_route))
25
- end
26
-
27
- test "should show message_route" do
28
- get :show, id: @message_route
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @message_route
34
- assert_response :success
35
- end
36
-
37
- test "should update message_route" do
38
- put :update, id: @message_route, message_route: @message_route.attributes
39
- assert_redirected_to message_route_path(assigns(:message_route))
40
- end
41
-
42
- test "should destroy message_route" do
43
- assert_difference('MessageRoute.count', -1) do
44
- delete :destroy, id: @message_route
45
- end
46
-
47
- assert_redirected_to message_routes_path
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageTypesControllerTest < ActionController::TestCase
4
- setup do
5
- @message_type = message_types(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:message_types)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create message_type" do
20
- assert_difference('MessageType.count') do
21
- post :create, message_type: @message_type.attributes
22
- end
23
-
24
- assert_redirected_to message_type_path(assigns(:message_type))
25
- end
26
-
27
- test "should show message_type" do
28
- get :show, id: @message_type
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @message_type
34
- assert_response :success
35
- end
36
-
37
- test "should update message_type" do
38
- put :update, id: @message_type, message_type: @message_type.attributes
39
- assert_redirected_to message_type_path(assigns(:message_type))
40
- end
41
-
42
- test "should destroy message_type" do
43
- assert_difference('MessageType.count', -1) do
44
- delete :destroy, id: @message_type
45
- end
46
-
47
- assert_redirected_to message_types_path
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessagesControllerTest < ActionController::TestCase
4
- setup do
5
- @message = messages(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:messages)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create message" do
20
- assert_difference('Message.count') do
21
- post :create, message: @message.attributes
22
- end
23
-
24
- assert_redirected_to message_path(assigns(:message))
25
- end
26
-
27
- test "should show message" do
28
- get :show, id: @message
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @message
34
- assert_response :success
35
- end
36
-
37
- test "should update message" do
38
- put :update, id: @message, message: @message.attributes
39
- assert_redirected_to message_path(assigns(:message))
40
- end
41
-
42
- test "should destroy message" do
43
- assert_difference('Message.count', -1) do
44
- delete :destroy, id: @message
45
- end
46
-
47
- assert_redirected_to messages_path
48
- end
49
- end
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- class BrowsingTest < ActionDispatch::PerformanceTest
5
- # Refer to the documentation for all available options
6
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
- # :output => 'tmp/performance', :formats => [:flat] }
8
-
9
- def test_homepage
10
- get '/'
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
- #
8
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
- # -- they do not yet inherit this setting
10
- fixtures :all
11
-
12
- # Add more helper methods to be used by all tests here...
13
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ApplicationTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ApplicationsHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageRoutesHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageTypesHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessagesHelperTest < ActionView::TestCase
4
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageRouteTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MessageTypeTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,118 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- admin_base = ENV['EVENTBUS_PORTAL_BASE'] || './admin'
4
- puts "Loading environment.rb from: #{admin_base}/config/"
5
-
6
- require 'eventbus/service'
7
- require 'eventbus/message'
8
- require "#{admin_base}/config/environment"
9
-
10
- class DispatcherService < EventBus::Service
11
-
12
- class ConfigurationError < RuntimeError
13
- end
14
-
15
- def initialize
16
- super("EVENT_BUS_CORE")
17
- self.listen_queue = "dispatcher"
18
- self.system_process = true
19
- end
20
-
21
-
22
- def process_message(incoming_msg)
23
-
24
- msg = EventBus::Message.new("EVENT_BUS_CORE")
25
- msg.load(incoming_msg)
26
-
27
- puts "Application Key: #{msg.application_id}"
28
- puts "Message ID: #{msg.message_id}"
29
- puts "Message type: #{msg.message_type}"
30
- puts "Message status: #{msg.status}"
31
-
32
- puts "Finding application for key #{msg.application_id}"
33
- app = Application.find_by_key(msg.application_id)
34
-
35
- if app.nil?
36
- puts "Unable to find an application with key #{msg.application_id}"
37
-
38
- msg.status = "DispatcherConfigurationError"
39
- msg.is_error = true
40
- msg.error_message = "Dispatcher has no application defined with key #{msg.application_id}"
41
- log_message nil, msg
42
- return
43
- end
44
-
45
- puts "Found application: #{app.inspect}"
46
-
47
- msg_type = app.message_types.find_by_name(msg.message_type)
48
-
49
- if msg_type.nil?
50
- log_message app, msg
51
- puts "No configuration found for Application Key #{app.key}, MessageType #{msg.message_type}"
52
-
53
- msg.status = "DispatcherConfigurationError"
54
- msg.is_error = true
55
- msg.error_message = "Application #{app.name} (#{app.key}) has no message type defined as: (#{msg.message_type})"
56
- log_message app, msg
57
- return
58
- else
59
- count = 0
60
- msg_type.message_routes.where(:incoming_status => msg.status).each do | route |
61
- puts "Found route: #{route.dispatch_to}"
62
- msg.send(:queue_name => route.dispatch_to)
63
- count = count + 1
64
-
65
- log_message app, msg, msg_type, route
66
- end
67
-
68
- if msg.is_error
69
- msg_type.message_routes.where(:match_errors => true).each do | route |
70
- puts "Matched error route: #{route.dispatch_to}"
71
- msg.send(:queue_name => route.dispatch_to)
72
- count = count + 1
73
-
74
- log_message app, msg, msg_type, route
75
- end
76
- end
77
-
78
- if count == 0
79
- puts "No routes found for MessageType #{msg_type.name} Status #{msg.status}. Will log only."
80
- log_message app, msg, msg_type
81
- end
82
- end
83
-
84
- end
85
-
86
-
87
- def log_message(application = nil, msg = nil, msg_type = nil, route = nil)
88
-
89
- log = Message.new
90
-
91
- unless application.nil?
92
- log.application_id = application.id
93
- end
94
-
95
- unless msg.nil?
96
- log.application_key = msg.application_id
97
- log.message_type_name = msg.message_type
98
- log.status = msg.status
99
- log.content = msg.dump
100
- log.is_error = msg.is_error
101
- log.message_guid = msg.message_id
102
- end
103
-
104
- unless msg_type.nil?
105
- log.message_type_id = msg_type.id
106
- end
107
-
108
- unless route.nil?
109
- log.dispatch_to = route.dispatch_to
110
- end
111
-
112
- log.save
113
-
114
- end
115
-
116
- end
117
-
118
- DispatcherService.new.start(:max_workers => 5)
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env railsrunner
2
-
3
- gem 'eventbus'
4
- require 'eventbus/service'
5
- require 'eventbus/message'
6
-
7
- class EmailRequest < EventBus::Message
8
- def initialize
9
- super("EVENT_BUS_CORE")
10
- end
11
-
12
- def contents
13
- get("web_message")
14
- end
15
- end
16
-
17
-
18
- class EmailService < EventBus::Service
19
-
20
- def initialize
21
- super("EVENT_BUS_CORE")
22
- self.listen_queue = "email"
23
- end
24
-
25
-
26
- def process_message(incoming_msg)
27
-
28
- msg = EmailRequest.new
29
- msg.load(incoming_msg[:payload])
30
-
31
- puts "Sending email with contents:"
32
- puts msg.contents
33
-
34
- msg.status = "EMAIL_SENT"
35
- msg.send
36
-
37
- end
38
-
39
- end
40
-
41
- EmailService.new.start