rabbitmq - How to send value with message on bunny queue on rabbitmp -
i want send values message in bunny message queue on rabbit server. there possibility of doing that. in advance.
finally found it.
in queue can able publish headers properties this,
in send.rb
conn = bunny.new conn.start ch= conn.create_channel q = ch.queue("queuename") msg = "message want send" q.publish( msg, :persistent => true, :headers => { :user_id => "10", :user_name => "xxx"} )
in receive.rb
conn = bunny.new conn.start ch = conn.create_channel q = ch.queue("queuename") ch.prefetch(1) begin q.subscribe(:ack => true, :block => true) |delivery_info, properties, body| puts "message : #{body}" puts "to userid : #{properties[:headers]["user_id"].to_s}\n" puts "to userid : #{properties[:headers]["user_name"].to_s}\n" ch.ack(delivery_info.delivery_tag) end rescue => e puts "error #{e.to_s}" conn.close end
we can userid 10 , username "xxx" in receiver end.
Comments
Post a Comment