From c61a58218065ca41d14b33352d6aefd0ebbf06e5 Mon Sep 17 00:00:00 2001 From: "J.C. Jones" Date: Thu, 12 Feb 2015 17:07:30 -0700 Subject: [PATCH] AMQP: Use a named topic exchange; prep for Activity Monitor. Instead of using default (direct) exchange, declare a topic exchange "boulder" for all queues. This permits a pub/sub model. --- amqp-rpc.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/amqp-rpc.go b/amqp-rpc.go index 4959c93e2..b82f9cb64 100644 --- a/amqp-rpc.go +++ b/amqp-rpc.go @@ -24,7 +24,9 @@ import ( // XXX: I *think* these constants are appropriate. // We will probably want to tweak these in the future. const ( - AmqpExchange = "" + AmqpExchange = "boulder" + AmqpExchangeType = "topic" + AmqpInternal = false AmqpDurable = false AmqpDeleteUnused = false AmqpExclusive = false @@ -48,6 +50,18 @@ func amqpConnect(url string) (ch *amqp.Channel, err error) { // A simplified way to declare and subscribe to an AMQP queue func amqpSubscribe(ch *amqp.Channel, name string) (msgs <-chan amqp.Delivery, err error) { + err = ch.ExchangeDeclare( + AmqpExchange, + AmqpExchangeType, + AmqpDurable, + AmqpDeleteUnused, + AmqpInternal, + AmqpNoWait, + nil) + if err != nil { + log.Fatalf("Could not declare exchange: %s", err) + } + q, err := ch.QueueDeclare( name, AmqpDurable,