Created
July 23, 2018 11:36
-
-
Save rbnpercy/c12d15c4ad53c79020112c584c1994f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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