From 6320e2ae0ef3563d34a560fb5e486345a839a4a1 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 15 Jun 2016 11:20:31 -0400 Subject: [PATCH] added consistent-hash exchange (same as pull request #68) --- include/exchangetype.h | 3 ++- src/channelimpl.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/exchangetype.h b/include/exchangetype.h index 8392153..5ef5c7a 100644 --- a/include/exchangetype.h +++ b/include/exchangetype.h @@ -24,7 +24,8 @@ enum ExchangeType fanout, direct, topic, - headers + headers, + consistent_hash }; /** diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index e285385..77f7a63 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -219,10 +219,13 @@ Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType typ { // convert exchange type std::string exchangeType; - if (type == ExchangeType::fanout) exchangeType = "fanout"; - if (type == ExchangeType::direct) exchangeType = "direct"; - if (type == ExchangeType::topic) exchangeType = "topic"; - if (type == ExchangeType::headers)exchangeType = "headers"; + + // convert the exchange type into a string + if (type == ExchangeType::fanout) exchangeType = "fanout"; + else if (type == ExchangeType::direct) exchangeType = "direct"; + else if (type == ExchangeType::topic) exchangeType = "topic"; + else if (type == ExchangeType::headers) exchangeType = "headers"; + else if (type == ExchangeType::consistent_hash) exchangeType = "x-consistent-hash"; // send declare exchange frame return push(ExchangeDeclareFrame(_id, name, exchangeType, (flags & passive) != 0, (flags & durable) != 0, false, arguments));