fixed autodelete flag for declaring an exchange and added support for internal exchange. this fixes #183
This commit is contained in:
parent
ba587aca13
commit
f5540e9af2
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a (mid-level) AMQP channel implementation
|
||||
*
|
||||
* @copyright 2014 - 2017 Copernica BV
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -170,6 +170,7 @@ public:
|
|||
* - durable exchange survives a broker restart
|
||||
* - autodelete exchange is automatically removed when all connected queues are removed
|
||||
* - passive only check if the exchange exist
|
||||
* - internal create an internal exchange
|
||||
*
|
||||
* @param name name of the exchange
|
||||
* @param type exchange type
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The various flags that are supported
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +38,7 @@ extern const int multiple;
|
|||
extern const int requeue;
|
||||
extern const int readable;
|
||||
extern const int writable;
|
||||
extern const int internal;
|
||||
|
||||
/**
|
||||
* End of namespace
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ Deferred &ChannelImpl::close()
|
|||
Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments)
|
||||
{
|
||||
// convert exchange type
|
||||
std::string exchangeType;
|
||||
const char *exchangeType = "";
|
||||
|
||||
// convert the exchange type into a string
|
||||
if (type == ExchangeType::fanout) exchangeType = "fanout";
|
||||
|
|
@ -261,8 +261,15 @@ Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType typ
|
|||
else if (type == ExchangeType::headers) exchangeType = "headers";
|
||||
else if (type == ExchangeType::consistent_hash) exchangeType = "x-consistent-hash";
|
||||
|
||||
// the boolean options
|
||||
bool passive = flags & AMQP::passive;
|
||||
bool durable = flags & AMQP::durable;
|
||||
bool autodelete = flags & AMQP::autodelete;
|
||||
bool internal = flags & AMQP::internal;
|
||||
bool nowait = flags & AMQP::nowait;
|
||||
|
||||
// send declare exchange frame
|
||||
return push(ExchangeDeclareFrame(_id, name, exchangeType, (flags & passive) != 0, (flags & durable) != 0, false, arguments));
|
||||
return push(ExchangeDeclareFrame(_id, name, exchangeType, passive, durable, autodelete, internal, nowait, arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP exchange declare frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -77,16 +77,17 @@ public:
|
|||
* @param type exchange type
|
||||
* @param passive do not create exchange if it does not exist
|
||||
* @param durable durable exchange
|
||||
* @param autodelete is this an auto-delete exchange?
|
||||
* @param internal is this an internal exchange
|
||||
* @param noWait do not wait on response
|
||||
* @param arguments additional arguments
|
||||
*/
|
||||
ExchangeDeclareFrame(uint16_t channel, const std::string& name, const std::string& type, bool passive, bool durable, bool noWait, const Table& arguments) :
|
||||
ExchangeFrame(channel, (uint32_t)(name.length() + type.length() + arguments.size() + 5)), // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes)
|
||||
ExchangeDeclareFrame(uint16_t channel, const std::string& name, const char *type, bool passive, bool durable, bool autodelete, bool internal, bool nowait, const Table& arguments) :
|
||||
ExchangeFrame(channel, (uint32_t)(name.length() + strlen(type) + arguments.size() + 5)), // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes)
|
||||
_name(name),
|
||||
_type(type),
|
||||
_bools(passive, durable, false, false, noWait),
|
||||
_arguments(arguments)
|
||||
{}
|
||||
_bools(passive, durable, autodelete, internal, nowait),
|
||||
_arguments(arguments) {}
|
||||
|
||||
/**
|
||||
* Construct parsing a declare frame from a received frame
|
||||
|
|
@ -162,6 +163,24 @@ public:
|
|||
{
|
||||
return _bools.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an autodelete exchange?
|
||||
* @return bool
|
||||
*/
|
||||
bool autoDelete() const
|
||||
{
|
||||
return _bools.get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an internal exchange?
|
||||
* @return bool
|
||||
*/
|
||||
bool internal() const
|
||||
{
|
||||
return _bools.get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not wait for a response
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The various flags that are supported
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
*/
|
||||
#include "includes.h"
|
||||
|
||||
|
|
@ -32,6 +32,7 @@ const int immediate = 0x1000;
|
|||
const int redelivered = 0x2000;
|
||||
const int multiple = 0x4000;
|
||||
const int requeue = 0x8000;
|
||||
const int internal = 0x10000;
|
||||
|
||||
/**
|
||||
* Flags for event loops
|
||||
|
|
|
|||
Loading…
Reference in New Issue