Function amqp_channel_close

Synopsis

#include <librabbitmq/amqp.h>

amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel, int code)

Description

Closes an channel

Parameters:

[ in ] state - the connection object

[ in ] channel - the channel identifier

[ in ] code - the reason for closing the channel, AMQP_REPLY_SUCCESS is a good default

Return
amqp_rpc_reply_t indicating success or failure
Since
v0.1

Mentioned in

Source

Lines 281-299 in librabbitmq/amqp_api.c. Line 1928 in librabbitmq/amqp.h.

amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state,
                                    amqp_channel_t channel, int code) {
  char codestr[13];
  amqp_method_number_t replies[2] = {AMQP_CHANNEL_CLOSE_OK_METHOD, 0};
  amqp_channel_close_t req;

  if (code < 0 || code > UINT16_MAX) {
    return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER);
  }

  req.reply_code = (uint16_t)code;
  req.reply_text.bytes = codestr;
  req.reply_text.len = sprintf(codestr, "%d", code);
  req.class_id = 0;
  req.method_id = 0;

  return amqp_simple_rpc(state, channel, AMQP_CHANNEL_CLOSE_METHOD, replies,
                         &req);
}





Add Discussion as Guest

Log in to DocsForge