Ejemplo n.º 1
0
/**
 *  declare an exchange

 *  @param  name        name of the exchange to declare
 *  @param  type        type of exchange
 *  @param  flags       additional settings for the exchange
 *  @param  arguments   additional arguments
 *
 *  This function returns a deferred handler. Callbacks can be installed
 *  using onSuccess(), onError() and onFinalize() methods.
 */
Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments)
{
    // 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";

    // send declare exchange frame
    return push(ExchangeDeclareFrame(_id, name, exchangeType, (flags & passive) != 0, (flags & durable) != 0, false, arguments));
}
Ejemplo n.º 2
0
/**
 *  declare an exchange

 *  @param  name        name of the exchange to declare
 *  @param  type        type of exchange
 *  @param  flags       additional settings for the exchange
 *  @param  arguments   additional arguments
 *
 *  This function returns a deferred handler. Callbacks can be installed
 *  using onSuccess(), onError() and onFinalize() methods.
 */
Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments)
{
    // convert exchange type
    const char *exchangeType = "";
    
    // 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";

    // 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, passive, durable, autodelete, internal, nowait, arguments));
}