Skip to content

Instantly share code, notes, and snippets.

@michaelklishin
Created April 17, 2014 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelklishin/fb4ae5a53a537cc73e4f to your computer and use it in GitHub Desktop.
Save michaelklishin/fb4ae5a53a537cc73e4f to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
Bundler.setup
require "bunny"
conn = Bunny.new
conn.start
ch = conn.create_channel
q = ch.queue("", exclusive: true)
q.bind(ch.topic("amq.topic"), routing_key: "builds").subscribe(block: true) do |_, _, payload|
puts "Payload: #{payload}"
end
#!/usr/bin/env ruby
Bundler.setup
require "mqtt"
c = MQTT::Client.connect(
remote_host: "127.0.0.1",
remote_port: 1883,
username: "guest",
password: "guest")
loop do
m = "Message @ #{Time.now.to_i}"
c.publish("builds", m)
puts "=> Published #{m}"
sleep 0.2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment