Class: StompServer::MemoryQueue

### Home Classes Methods

### In Files

- lib/stomp_server/queue/memory_queue.rb

### Parent

Object

### Methods

- ::new
- #assign_id
- #dequeue
- #enqueue
- #message_for?
- #monitor
- #requeue
- #stop

### Files

- History.txt
- Manifest.txt
- README.txt
- README.txt

### Class/Module Index

Quicksearch

- StompServer
- StompServer::ActiveRecordQueue
- StompServer::Configurator
- StompServer::DBMQueue
- StompServer::FileQueue
- StompServer::MemoryQueue
- StompServer::Protocols
- StompServer::Protocols::Http
- StompServer::Protocols::Stomp
- StompServer::Queue
- StompServer::QueueManager
- StompServer::QueueMonitor
- StompServer::Run
- StompServer::StompAuth
- StompServer::StompFrame
- StompServer::StompFrameRecognizer
- StompServer::StompId
- StompServer::StompUser
- StompServer::TestServer
- StompServer::TopicManager
- Mongrel
- Mongrel::HttpRequest
- ArMessage

No matching classes.

# StompServer::MemoryQueue

### Attributes

checkpoint_interval[RW]

### Public Class Methods

new() click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 6
    def initialize
      @frame_index =0
      @stompid = StompServer::StompId.new
      @stats = Hash.new
      @messages = Hash.new { Array.new }
      puts "MemoryQueue initialized"
    end

### Public Instance Methods

assign_id(frame, dest) click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 55
    def assign_id(frame, dest)
      frame.headers['message-id'] = @stompid[@frame_index]
    end

dequeue(dest) click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 25
    def dequeue(dest)
      if frame = @messages[dest].shift
        @stats[dest][:dequeued] += 1
        return frame
      else
        return false
      end
    end

enqueue(dest,frame) click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 34
    def enqueue(dest,frame)
      @frame_index += 1
      if @stats[dest]
        @stats[dest][:enqueued] += 1
      else
        @stats[dest] = Hash.new
        @stats[dest][:enqueued] = 1
        @stats[dest][:dequeued] = 0
      end
      assign_id(frame, dest)
      requeue(dest, frame)
    end

message_for?(dest) click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 51
    def message_for?(dest)
      !@messages[dest].empty?
    end

monitor() click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 17
    def monitor
      stats = Hash.new
      @messages.keys.each do |dest|
       stats[dest] = {'size' => @messages[dest].size, 'enqueued' => @stats[dest][:enqueued], 'dequeued' => @stats[dest][:dequeued]}
      end
      stats
    end

requeue(dest,frame) click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 47
    def requeue(dest,frame)
      @messages[dest] += [frame]
    end

stop() click to toggle source

    # File lib/stomp_server/queue/memory_queue.rb, line 14
    def stop
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.