Class: Katello::Qpid::Connection::Receiver

Inherits:
Qpid::Proton::MessagingHandler
  • Object
show all
Defined in:
app/lib/katello/qpid/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, connection_options, address, handler) ⇒ Receiver

Returns a new instance of Receiver.



53
54
55
56
57
58
59
60
61
# File 'app/lib/katello/qpid/connection.rb', line 53

def initialize(url, connection_options, address, handler)
  super()
  @url = url
  @connection_options = connection_options.merge(
    idle_timeout: 30
  )
  @address = address
  @handler = handler
end

Instance Method Details

#on_container_start(container) ⇒ Object



63
64
65
66
# File 'app/lib/katello/qpid/connection.rb', line 63

def on_container_start(container)
  c = container.connect(@url, @connection_options)
  c.open_receiver(@address)
end

#on_message(_delivery, message) ⇒ Object



68
69
70
71
# File 'app/lib/katello/qpid/connection.rb', line 68

def on_message(_delivery, message)
  received = Katello::Messaging::ReceivedMessage.new(body: message.body)
  @handler.handle(received)
end