Skip to content

Instantly share code, notes, and snippets.

@rbnpercy
Created July 23, 2018 11:36
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 rbnpercy/c12d15c4ad53c79020112c584c1994f5 to your computer and use it in GitHub Desktop.
Save rbnpercy/c12d15c4ad53c79020112c584c1994f5 to your computer and use it in GitHub Desktop.
require "rubygems"
require "bunny"
require "json"
# Returns a connection instance
conn = Bunny.new ENV['CLOUDAMQP_URL']
# The connection will be established when start is called
conn.start
# create a channel in the TCP connection
ch = conn.create_channel
# Declare a queue with a given name, examplequeue. In this example is a durable shared queue used.
q = ch.queue("examplequeue", :durable => true)
# Bind a queue to an exchange
x = ch.direct("example.exchange", :durable => true)
q.bind(x, :routing_key => "process")
# Publish a message
information_message = "{\"email\": \"example@mail.com\",\"name\": \"name\",\"size\": \"size\"}"
x.publish(information_message,
:timestamp => Time.now.to_i,
:routing_key => "process"
)
sleep 1.0
conn.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment