Ruby 关于红宝石的胡萝卜宝石

Ruby 关于红宝石的胡萝卜宝石,ruby,carrot,Ruby,Carrot,我使用carrot gem在ruby中发布消息,示例代码如下: 代码: require 'carrot' q = Carrot.queue('testqueue', :durable => true) q.publish("sample data") 有人能告诉我如何使用路由密钥发布相同的数据吗?我对AMQP的了解有限,但我在使用谷歌方面的非凡能力让我发现,使用路由密钥: 我们将改用直接交换。一种新的路由算法 直接交换很简单——一条消息被发送到其绑定的队列 密钥与消息的路由密钥完全匹

我使用carrot gem在ruby中发布消息,示例代码如下:

代码:

require 'carrot'

q = Carrot.queue('testqueue', :durable => true)

q.publish("sample data")

有人能告诉我如何使用路由密钥发布相同的数据吗?

我对AMQP的了解有限,但我在使用谷歌方面的非凡能力让我发现,使用路由密钥:

我们将改用直接交换。一种新的路由算法 直接交换很简单——一条消息被发送到其绑定的队列 密钥与消息的路由密钥完全匹配

这就是你如何使用胡萝卜和直接交换:

require 'carrot'

c = Carrot.new
q = c.queue('queue_name', {
  host: 'example.com',
  user: 'username',
  pass: 'passwd',
  vhost: '/',
  auto_delete: true
})
c.direct("name.exchange", { :durable => true })