alanxz / rabbitmq-c

RabbitMQ C client
MIT License
1.77k stars 672 forks source link

Expose 'nowait' exchange and queue parameter. #840

Open WojciechSobczak opened 4 months ago

WojciechSobczak commented 4 months ago

I noticed that in exchange declare:

/**
 * amqp_exchange_declare
 *
 * @param [in] state connection state
 * @param [in] channel the channel to do the RPC on
 * @param [in] exchange exchange
 * @param [in] type type
 * @param [in] passive passive
 * @param [in] durable durable
 * @param [in] auto_delete auto_delete
 * @param [in] internal internal
 * @param [in] arguments arguments
 * @returns amqp_exchange_declare_ok_t
 */
AMQP_EXPORT
amqp_exchange_declare_ok_t *AMQP_CALL amqp_exchange_declare(
    amqp_connection_state_t state, amqp_channel_t channel,
    amqp_bytes_t exchange, amqp_bytes_t type, amqp_boolean_t passive,
    amqp_boolean_t durable, amqp_boolean_t auto_delete, amqp_boolean_t internal,
    amqp_table_t arguments) {
  amqp_exchange_declare_t req;
  req.ticket = 0;
  req.exchange = exchange;
  req.type = type;
  req.passive = passive;
  req.durable = durable;
  req.auto_delete = auto_delete;
  req.internal = internal;
  req.nowait = 0;
  req.arguments = arguments;

  return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_DECLARE_METHOD,
                                 AMQP_EXCHANGE_DECLARE_OK_METHOD, &req);
}

and in queue declare:

/**
 * amqp_queue_declare
 *
 * @param [in] state connection state
 * @param [in] channel the channel to do the RPC on
 * @param [in] queue queue
 * @param [in] passive passive
 * @param [in] durable durable
 * @param [in] exclusive exclusive
 * @param [in] auto_delete auto_delete
 * @param [in] arguments arguments
 * @returns amqp_queue_declare_ok_t
 */
AMQP_EXPORT
amqp_queue_declare_ok_t *AMQP_CALL amqp_queue_declare(
    amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue,
    amqp_boolean_t passive, amqp_boolean_t durable, amqp_boolean_t exclusive,
    amqp_boolean_t auto_delete, amqp_table_t arguments) {
  amqp_queue_declare_t req;
  req.ticket = 0;
  req.queue = queue;
  req.passive = passive;
  req.durable = durable;
  req.exclusive = exclusive;
  req.auto_delete = auto_delete;
  req.nowait = 0;
  req.arguments = arguments;

  return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_DECLARE_METHOD,
                                 AMQP_QUEUE_DECLARE_OK_METHOD, &req);
}

nowait parameter is not exposed by API for reason I don't know about.

Is it possible to expose it as function parameter? And if not, is there any way to set it?

Thanks in advance.

manchicken commented 3 months ago

I'm curious what would be gained, but I'm also curious how you'd want to see this working in the case that you tried to create a channel but the operation failed for some reason.