Module: ActiveMessaging
- Defined in:
- lib/activemessaging/filter.rb,
lib/activemessaging.rb,
lib/activemessaging/adapter.rb,
lib/activemessaging/gateway.rb,
lib/activemessaging/railtie.rb,
lib/activemessaging/version.rb,
lib/activemessaging/processor.rb,
lib/activemessaging/test_helper.rb,
lib/activemessaging/adapters/jms.rb,
lib/activemessaging/adapters/wmq.rb,
lib/activemessaging/base_message.rb,
lib/activemessaging/adapters/amqp.rb,
lib/activemessaging/adapters/asqs.rb,
lib/activemessaging/adapters/base.rb,
lib/activemessaging/adapters/test.rb,
lib/activemessaging/adapters/stomp.rb,
lib/activemessaging/adapters/synch.rb,
lib/activemessaging/message_sender.rb,
lib/activemessaging/threaded_poller.rb,
lib/activemessaging/adapters/beanstalk.rb,
lib/activemessaging/adapters/reliable_msg.rb,
lib/generators/active_messaging/install/install_generator.rb,
lib/generators/active_messaging/processor/processor_generator.rb
Overview
This is meant to avoid the need to use a broker in development, and generally make development mode easier
Defined Under Namespace
Modules: Adapter, Adapters, MessageSender, TestHelper
Classes: AbortMessageException, BaseMessage, Destination, Filter, Gateway, InstallGenerator, MessageReceiver, MockLogger, Processor, ProcessorGenerator, Railtie, StopFilterException, StopProcessingException, Subscription, TestMessage, ThreadedPoller, Worker
Constant Summary
collapse
- ROOT =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
- VERSION =
"0.13.1"
- @@logger =
nil
Class Method Summary
collapse
Class Method Details
.app_env ⇒ Object
42
43
44
|
# File 'lib/activemessaging.rb', line 42
def self.app_env
@@app_env ||= (ENV['APP_ENV'] || (defined?(::Rails) && ::Rails.env) || ENV['RAILS_ENV'] || 'development')
end
|
.app_root ⇒ Object
38
39
40
|
# File 'lib/activemessaging.rb', line 38
def self.app_root
@@app_root ||= (ENV['APP_ROOT'] || (defined?(::Rails) && ::Rails.root) || ENV['RAILS_ROOT'] || File.expand_path(Dir.pwd))
end
|
.load_activemessaging ⇒ Object
103
104
105
106
107
|
# File 'lib/activemessaging.rb', line 103
def self.load_activemessaging
load_extensions
load_config
load_processors
end
|
.load_config ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/activemessaging.rb', line 66
def self.load_config
if Dir["#{app_root}/app/processors/*.rb"].size() <= 1
return
end
path = File.expand_path("#{app_root}/config/messaging.rb")
begin
load path
rescue
raise $!, " ActiveMessaging: problems trying to load '#{path}': \n\t#{$!.message}"
end
end
|
.load_extensions ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/activemessaging.rb', line 46
def self.load_extensions
require 'logger'
require 'activemessaging/gateway'
require 'activemessaging/adapter'
require 'activemessaging/message_sender'
require 'activemessaging/processor'
require 'activemessaging/filter'
require 'activemessaging/trace_filter'
Dir[File.join(ROOT, 'lib', 'activemessaging', 'adapters', '*.rb')].each do |a|
begin
adapter_name = File.basename(a, ".rb")
require 'activemessaging/adapters/' + adapter_name
rescue RuntimeError, LoadError => e
logger.warn "ActiveMessaging: adapter #{adapter_name} not loaded: #{ e.message }"
end
end
end
|
.load_processors(first = true) ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/activemessaging.rb', line 81
def self.load_processors(first=true)
logger.info "ActiveMessaging: Loading #{app_root}/app/processors/application_processor.rb" if first
load "#{app_root}/app/processors/application_processor.rb" if File.exist?("#{app_root}/app/processors/application_processor.rb")
Dir["#{app_root}/app/processors/*.rb"].each do |f|
unless f.match(/\/application_processor.rb/)
logger.info "ActiveMessaging: Loading #{f}" if first
load f
end
end
end
|
.logger ⇒ Object
27
28
29
30
31
32
|
# File 'lib/activemessaging.rb', line 27
def self.logger
@@logger = nil unless defined? @@logger
@@logger ||= Rails.logger if defined? Rails
@@logger ||= Logger.new(STDOUT)
@@logger
end
|
.logger=(logger) ⇒ Object
34
35
36
|
# File 'lib/activemessaging.rb', line 34
def self.logger=(logger)
@@logger = logger
end
|
.reload_activemessaging ⇒ Object
.start ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/activemessaging.rb', line 109
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
# ...
end
EOM
puts err_msg
logger.error err_msg
exit
end
Gateway.start
end
|