Skip to content

Commit 6c2539d

Browse files
author
Caique Hitoshi Mitsuoka
committed
Update ruby tutorial two
1 parent 7a4de03 commit 6c2539d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

ruby/new_task.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
#!/usr/bin/env ruby
2-
# encoding: utf-8
2+
require 'bunny'
33

4-
require "bunny"
4+
connection = Bunny.new(automatically_recover: false)
5+
connection.start
56

6-
conn = Bunny.new(:automatically_recover => false)
7-
conn.start
7+
channel = connection.create_channel
8+
queue = channel.queue('task_queue', durable: true)
89

9-
ch = conn.create_channel
10-
q = ch.queue("task_queue", :durable => true)
10+
message = ARGV.empty? ? 'Hello World!' : ARGV.join(' ')
1111

12-
msg = ARGV.empty? ? "Hello World!" : ARGV.join(" ")
12+
queue.publish(message, persistent: true)
13+
puts " [x] Sent #{message}"
1314

14-
q.publish(msg, :persistent => true)
15-
puts " [x] Sent #{msg}"
16-
17-
conn.close
15+
connection.close

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy