Class: SMQueue::AmqpAdapter

Inherits:
Adapter show all
Defined in:
lib/smqueue/adapters/amqp.rb

Defined Under Namespace

Classes: Configuration

Instance Method Summary collapse

Methods inherited from Adapter

#close, create, #open

Methods inherited from Doodle

#to_hash

Constructor Details

#initialize(*args) ⇒ AmqpAdapter

Returns a new instance of AmqpAdapter.



11
12
13
14
15
# File 'lib/smqueue/adapters/amqp.rb', line 11

def initialize(*args)
  super
  options = args.first
  @configuration = options[:configuration]
end

Instance Method Details

#get(*args, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smqueue/adapters/amqp.rb', line 24

def get(*args, &block)
  if block_given?
    EM.run {
      channel.subscribe { |header, body|
        yield ::SMQueue::Message(:headers => header, :body => body)
      }
    }
  else
    raise "TODO: Implement me"
  end
end

#put(*args, &block) ⇒ Object



17
18
19
20
21
22
# File 'lib/smqueue/adapters/amqp.rb', line 17

def put(*args, &block)
  AMQP.start {
    channel.publish(args[0])
    AMQP.stop { EM.stop }
  }
end