Class: Backstage::Destination
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Resource
#association_chain, included, #resource, #to_hash
Methods included from HasMBean
#<=>, #full_name, included, #initialize, #mbean_info, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Backstage::HasMBean
Instance Attribute Details
#enumerable_options ⇒ Object
Returns the value of attribute enumerable_options.
25
26
27
|
# File 'lib/destinations/models/destination.rb', line 25
def enumerable_options
@enumerable_options
end
|
Class Method Details
.display_name(name) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/destinations/models/destination.rb', line 75
def self.display_name(name)
display_name = name.gsub( /jms\..*?\./, '' )
display_name = 'Backgroundable' if display_name =~ %r{/queues/.*/tasks/torquebox_backgroundable}
display_name = "#{$1.classify}Task" if display_name =~ %r{/queues/torquebox/.*/tasks/(.*)$}
display_name
end
|
27
28
29
|
# File 'lib/destinations/models/destination.rb', line 27
def self.filter
"org.hornetq:address=\"#{jms_prefix}\",*,type=Queue"
end
|
.to_hash_attributes ⇒ Object
31
32
33
|
# File 'lib/destinations/models/destination.rb', line 31
def self.to_hash_attributes
super + [:display_name, :app, :app_name, :status, :message_count, :delivering_count, :scheduled_count, :messages_added, :consumer_count]
end
|
Instance Method Details
82
83
84
|
# File 'lib/destinations/models/destination.rb', line 82
def app
name =~ %r{/queues/torquebox/(.*?)/} ? App.find( "torquebox.apps:name=#{$1}" ) : nil
end
|
86
87
88
|
# File 'lib/destinations/models/destination.rb', line 86
def app_name
name =~ %r{/queues/torquebox/(.*?)/} ? $1 : 'n/a'
end
|
#available_actions ⇒ Object
109
110
111
112
|
# File 'lib/destinations/models/destination.rb', line 109
def available_actions
actions = status == 'Running' ? %w{ pause } : %w{ resume }
actions << 'clear'
end
|
#browsable_message_count ⇒ Object
35
36
37
|
# File 'lib/destinations/models/destination.rb', line 35
def browsable_message_count
message_count - delivering_count
end
|
100
101
102
103
|
# File 'lib/destinations/models/destination.rb', line 100
def clear
mbean.removeMessages('')
self
end
|
#display_name ⇒ Object
65
66
67
|
# File 'lib/destinations/models/destination.rb', line 65
def display_name
self.class.display_name( name )
end
|
#each(options = { }) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/destinations/models/destination.rb', line 45
def each(options = { })
message_count = 0
processed_messages = 0
offset = options[:offset].to_i || 0
limit = options[:limit] ? options[:limit].to_i : nil
jms_destination.each do |message|
message_count += 1
if message_count > offset
message = Message.new( message )
message.parent = self
yield message
processed_messages += 1
end
return if limit and processed_messages > limit
end
rescue Exception => ex
Backstage.logger.warn "WARNING - failed to access messages for queue #{jndi_name}: #{ex}"
Backstage.logger.warn ex
end
|
#jms_destination ⇒ Object
39
40
41
42
43
|
# File 'lib/destinations/models/destination.rb', line 39
def jms_destination
@jms_destination ||= TorqueBox::Messaging::Queue.new( jndi_name )
@jms_destination.enumerable_options = enumerable_options
@jms_destination
end
|
#jndi_name ⇒ Object
69
70
71
72
73
|
# File 'lib/destinations/models/destination.rb', line 69
def jndi_name
jndi_name = name.gsub( self.class.jms_prefix, '' )
jndi_name = "/queue/#{jndi_name}" if %w{ DLQ ExpiryQueue }.include?( jndi_name )
jndi_name
end
|
90
91
92
93
|
# File 'lib/destinations/models/destination.rb', line 90
def pause
super
self
end
|
95
96
97
98
|
# File 'lib/destinations/models/destination.rb', line 95
def resume
super
self
end
|
105
106
107
|
# File 'lib/destinations/models/destination.rb', line 105
def status
mbean.paused ? 'Paused' : 'Running'
end
|