AMQP
The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. The defining features of AMQP are message orientation, queuing, routing (including point-to-point and publish-and-subscribe), reliability and security.[1]
Ref. Wikipedia

Client

With bunny

Gem: bunny
No authenticattion, publish a message:
1
#!/usr/bin/env ruby
2
3
require 'bunny'
4
5
options = {
6
host: '10.10.10.190',
7
port: 5672
8
}
9
connection = Bunny.new(options)
10
connection.start
11
12
channel = connection.create_channel
13
exchange = channel.fanout('logs')
14
15
message = ARGV.empty? ? 'Hello World!' : ARGV.join(' ')
16
17
exchange.publish(message)
18
puts " [x] Sent #{message}"
19
20
connection.close
Copied!
AMQPLAIN authentication, direct durable exchange, publish a file retrieved via HTTP:
1
#!/usr/bin/env ruby
2
3
require 'bunny'
4
5
options = {
6
host: '10.0.0.1',
7
port: 5672,
8
user: 'username',
9
password: 'password'
10
}
11
connection = Bunny.new(options)
12
connection.start
13
14
channel = connection.create_channel
15
exchange = channel.direct('my_channel', durable: true)
16
17
message = ARGV.empty? ? 'http://127.0.0.1:8080/file.zip' : ARGV.join(' ')
18
19
exchange.publish(message)
20
puts " [x] Sent #{message}"
21
22
connection.close
Copied!
Ref.:
Last modified 5mo ago
Copy link