Class: ReliableMsg::MessageStore::Base

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped
Defined in:
lib/ap4r/message_store_ext.rb,
lib/ap4r/queue_manager_ext_debug.rb

Overview

:nodoc:

Direct Known Subclasses

Memory

Constant Summary collapse

@@use_mysql_extention =
true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



53
54
55
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 53

def cache
  @cache
end

#mutexObject (readonly)

Returns the value of attribute mutex.



53
54
55
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 53

def mutex
  @mutex
end

#queuesObject (readonly)

Returns the value of attribute queues.



53
54
55
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 53

def queues
  @queues
end

#topicsObject (readonly)

Returns the value of attribute topics.



53
54
55
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 53

def topics
  @topics
end

Class Method Details

.configure(config, logger) ⇒ Object

Returns a message store from the specified configuration (previously created with configure).

:call-seq:

Base::configure(config, logger) -> store

Raises:

  • (RuntimeError)


40
41
42
43
44
45
46
47
48
49
# File 'lib/ap4r/message_store_ext.rb', line 40

def self.configure config, logger
  if config["type"].downcase.starts_with?("activerecord")
    type = config["type"].downcase.split("_").first
  else
    type = config["type"].downcase
  end
  cls = @@stores[type]
  raise RuntimeError, format(ERROR_INVALID_MESSAGE_STORE, type) unless cls
  cls.new config, logger
end

Instance Method Details

#activateObject



57
58
59
60
61
62
63
64
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 57

def activate
  activate_original
  @mutex.extend DRbUndumped
  # TODO: queues/topics/cache should be DRbUndumped? 2007/06/06 by shino
  # @queues.extend DRbUndumped
  # @topics.extend DRbUndumped
  # @cache.extend DRbUndumped
end

#activate_originalObject



55
# File 'lib/ap4r/queue_manager_ext_debug.rb', line 55

alias activate_original activate

#stale_queue(targets) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ap4r/message_store_ext.rb', line 12

def stale_queue targets
  queue_names = targets.split(/[\s;]/).
    select{|queue| !queue.empty? }.
    map{|queue| queue.strip! || queue }

  queue_and_created = @queues.select{|queue, messages|
    messages && (messages.size > 0) &&
    queue_names.any?{|mq|
      if mq[-1] == '*'[0]
        queue[0..(mq.size-2)] == mq[0..-2]
      else
        queue == mq
      end
    }
  }.map{|queue, messages|
    [queue, messages[0][:created]]
  }.min {|q1, q2|
    q1[1] <=> q2[1]
  }
  queue_and_created ? queue_and_created[0] : nil
end