Skip to content

Instantly share code, notes, and snippets.

@lifez
Created January 2, 2017 08:51
Show Gist options
  • Select an option

  • Save lifez/d6d58d7ecac04dc79889eaccf35912d1 to your computer and use it in GitHub Desktop.

Select an option

Save lifez/d6d58d7ecac04dc79889eaccf35912d1 to your computer and use it in GitHub Desktop.
# ใช้ gem ชื่อ bunny ในการต่อไปที่ RabbitMQ Server
require "bunny"
STDOUT.sync = true
## ต่อ RabbitMQ ผ่าน protocol amqp ด้วย user:guest , password: guest ไปที่ my-rabbit port 5672
conn = Bunny.new("amqp://guest:guest@my-rabbit:5672")
conn.start
## สร้าง Queue ที่ชื่อว่า "Test_Queue"
ch = conn.create_channel
q = ch.queue("Test_Queue", :durable => true)
## Publish Message ไปให้ Queue ที่เราสร้างไว้
q.publish("Test Message", :timestamp => Time.now.to_i, :persistent => true)
sleep 1.0
conn.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment