Module: ModernTimes::JMS::Worker::ClassMethods

Defined in:
lib/modern_times/jms/worker.rb

Instance Method Summary collapse

Instance Method Details

#create_supervisor(manager, worker_options) ⇒ Object



41
42
43
# File 'lib/modern_times/jms/worker.rb', line 41

def create_supervisor(manager, worker_options)
  Supervisor.new(manager, self, {}, worker_options)
end

#default_fail_queue_targetObject

Defines the default value of the fail_queue_target. For extenders of this class, the default will be true but extenders can change this (RequestWorker returns exceptions to the caller so it defaults to false).



76
77
78
# File 'lib/modern_times/jms/worker.rb', line 76

def default_fail_queue_target
  true
end

#dest_optionsObject



54
55
56
# File 'lib/modern_times/jms/worker.rb', line 54

def dest_options
  @dest_options ||= {}
end

#fail_queue(target, opts = {}) ⇒ Object

Set the fail_queue target =>

boolean
  true - exceptions in the worker will cause the message to be forwarded to the queue of <default-name>Fail
    For instance, an Exception in FooWorker#perform will forward the message to the queue FooFail
  false - exceptions will not result in the message being forwarded to a fail queue
string - equivalent to true but the string defines the name of the fail queue


65
66
67
# File 'lib/modern_times/jms/worker.rb', line 65

def fail_queue(target, opts={})
  @fail_queue_target = name
end

#fail_queue_targetObject



69
70
71
72
# File 'lib/modern_times/jms/worker.rb', line 69

def fail_queue_target
  # Don't overwrite if the user set to false, only if it was never set
  @fail_queue_target
end

#queue(name, opts = {}) ⇒ Object



50
51
52
# File 'lib/modern_times/jms/worker.rb', line 50

def queue(name, opts={})
  dest_options[:queue_name] = name.to_s
end

#virtual_topic(name, opts = {}) ⇒ Object



45
46
47
48
# File 'lib/modern_times/jms/worker.rb', line 45

def virtual_topic(name, opts={})
  # ActiveMQ only
  dest_options[:virtual_topic_name] = name.to_s
end