Module: Qwirk

Extended by:
Loggable
Defined in:
lib/qwirk/publisher.rb,
lib/qwirk.rb,
lib/qwirk/task.rb,
lib/qwirk/engine.rb,
lib/qwirk/remote.rb,
lib/qwirk/worker.rb,
lib/qwirk/manager.rb,
lib/qwirk/loggable.rb,
lib/qwirk/base_worker.rb,
lib/qwirk/reply_worker.rb,
lib/qwirk/remote/client.rb,
lib/qwirk/remote/worker.rb,
lib/qwirk/publish_handle.rb,
lib/qwirk/adapter_factory.rb,
lib/qwirk/batch/job_status.rb,
lib/qwirk/marshal_strategy.rb,
lib/qwirk/remote_exception.rb,
lib/qwirk/batch/file_worker.rb,
lib/qwirk/adapter/inline/worker.rb,
lib/qwirk/marshal_strategy/bson.rb,
lib/qwirk/marshal_strategy/json.rb,
lib/qwirk/marshal_strategy/none.rb,
lib/qwirk/marshal_strategy/ruby.rb,
lib/qwirk/marshal_strategy/yaml.rb,
lib/qwirk/adapter/in_memory/queue.rb,
lib/qwirk/adapter/in_memory/topic.rb,
lib/qwirk/marshal_strategy/string.rb,
lib/qwirk/adapter/in_memory/worker.rb,
lib/qwirk/adapter/inline/publisher.rb,
lib/qwirk/adapter/in_memory/factory.rb,
lib/qwirk/batch/parse_file_strategy.rb,
lib/qwirk/adapter/base/worker_config.rb,
lib/qwirk/adapter/in_memory/publisher.rb,
lib/qwirk/batch/acquire_file_strategy.rb,
lib/qwirk/adapter/inline/worker_config.rb,
lib/qwirk/adapter/in_memory/reply_queue.rb,
lib/qwirk/adapter/in_memory/worker_config.rb,
lib/qwirk/adapter/base/expanding_worker_config.rb

Overview

Handle Messaging and Queuing using JMS

Defined Under Namespace

Modules: Adapter, BaseWorker, Batch, Loggable, MarshalStrategy, Remote, ReplyWorker, Task, Worker Classes: AdapterFactory, Engine, Manager, MyBean, PublishHandle, Publisher, RemoteException

Constant Summary collapse

DEFAULT_NAME =
'Qwirk'
@@config =
nil
@@environment =
nil
@@hash =
{}

Class Method Summary collapse

Methods included from Loggable

default_logger, logger, logger=, rails_logger

Class Method Details

.[](adapter_key) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/qwirk.rb', line 47

def self.[](adapter_key)
  if @@config.nil?
    if defined?(Rails)
      # Allow user to use a different adapter w/o modifying qwirk.yml which could be checked in and hose other users
      self.environment = ENV['QWIRK_ENV'] || Rails.env
      self.config_file = Rails.root.join('config', 'qwirk.yml')
      Manager.default_options = {
          :persist_file    => Rails.root.join('log',    'qwirk_persist.yml'),
          :worker_file     => Rails.root.join('config', 'qwirk_workers.yml'),
          :env             => @@environment,
      }
    end
  end
  raise 'Qwirk not configured' unless @@config && @@config[adapter_key]
  @@hash[adapter_key] ||= begin
    Qwirk.logger.debug {"Creating Qwirk::AdapterFactory key=#{adapter_key} config=#{@@config[adapter_key].inspect}"}
    config = @@config[adapter_key]
    raise "No config for key #{adapter_key}, keys=#{config.keys.inspect}" unless config
    # Create the adapter, turning all the keys into symbols
    Qwirk::AdapterFactory.new(adapter_key, Hash[config.map{|(k,v)| [k.to_sym,v]}])
  end
end

.config=(config) ⇒ Object



25
26
27
28
29
# File 'lib/qwirk.rb', line 25

def self.config=(config)
  #if config.has_key?(:adapter)
  @@config = config
  ::Rumx::Bean.root.bean_add_child(DEFAULT_NAME, MyBean.new(@@hash))
end

.config_file=(config_file) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/qwirk.rb', line 35

def self.config_file=(config_file)
  raise "No such file: #{config_file}" unless File.exist?(config_file)
  config = YAML.load(ERB.new(File.read(config_file), nil, '-').result(binding))
  config = config[@@environment] if config && @@environment
  if config.has_key?(:adapter) || config.has_key?('adapter')
    # Single level, one default adapter
    @@config = {'default' => config}
  else
    @@config = config
  end
end

.create_manager(options = {}) ⇒ Object



85
86
87
# File 'lib/qwirk.rb', line 85

def self.create_manager(options={})
  self['default'].create_manager(options)
end

.create_publisher(options = {}) ⇒ Object

From here on down are proxies to the default adapter to keep the API simpler for setups with a single adapter TODO: Allow the setting of the default adapter



81
82
83
# File 'lib/qwirk.rb', line 81

def self.create_publisher(options={})
  self['default'].create_publisher(options)
end

.create_publisher_impl(queue_name, topic_name, options, response_options) ⇒ Object



89
90
91
# File 'lib/qwirk.rb', line 89

def self.create_publisher_impl(queue_name, topic_name, options, response_options)
  self['default'].create_publisher_impl(queue_name, topic_name, options, response_options)
end

.environment=(environment) ⇒ Object



31
32
33
# File 'lib/qwirk.rb', line 31

def self.environment=(environment)
  @@environment = environment
end

.fail_queue_name(queue_name) ⇒ Object



74
75
76
# File 'lib/qwirk.rb', line 74

def self.fail_queue_name(queue_name)
  return "#{queue_name.to_s}Fail"
end

.in_process?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/qwirk.rb', line 93

def self.in_process?
  self['default'].in_process?
end

.register_adapter(key, publisher_class, worker_config_class, &block) ⇒ Object



70
71
72
# File 'lib/qwirk.rb', line 70

def self.register_adapter(key, publisher_class, worker_config_class, &block)
  AdapterFactory.register(key, publisher_class, worker_config_class, &block)
end