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.
This commit is contained in:
J.C. Jones 2015-02-12 17:07:30 -07:00
parent 63997f481b
commit 2b34b9f6eb
1 changed files with 15 additions and 1 deletions

View File

@ -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,