Sha256: 06e4f89b9ab9ea4e5dafaa20044cc678788cb1cb771a551b709a527b241ab0f1
Contents?: true
Size: 966 Bytes
Versions: 18
Compression:
Stored size: 966 Bytes
Contents
#!/usr/bin/env ruby require 'manageiq-messaging' require_relative "common" Thread::abort_on_exception = true class ProducerConsumer < Common def run ManageIQ::Messaging::Client.open(q_options) do |client| puts "producer" 5.times do |i| client.publish_message( :service => 'ems_operation', :affinity => 'ems_amazon1', :message => 'power_on', :payload => { :ems_ref => 'u987', :id => i.to_s, } ) end puts "produced 5 messages" puts "consumer" client.subscribe_messages(:service => 'ems_operation', :affinity => 'ems_amazon1', :auto_ack => false) do |messages| messages.each do |msg| do_stuff(msg) msg.ack end end sleep(5) puts "consumed" end end def do_stuff(msg) puts "GOT MESSAGE: #{msg.message}: #{msg.payload}" end end ProducerConsumer.new.parse.run
Version data entries
18 entries across 18 versions & 1 rubygems