Function amqp_connection_close

Synopsis

#include <librabbitmq/amqp.h>

amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state, int code)

Description

Closes the entire connection

Implicitly closes all channels and informs the broker the connection is being closed, after receiving acknowledgment from the broker it closes the socket.

Parameters:

[ in ] state - the connection object

[ in ] code - the reason code for closing the connection. AMQP_REPLY_SUCCESS is a good default.

Return
amqp_rpc_reply_t indicating the result
Since
v0.1

Mentioned in

Source

Lines 301-318 in librabbitmq/amqp_api.c. Line 1946 in librabbitmq/amqp.h.

amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state,
                                       int code) {
  char codestr[13];
  amqp_method_number_t replies[2] = {AMQP_CONNECTION_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, 0, AMQP_CONNECTION_CLOSE_METHOD, replies, &req);
}





Add Discussion as Guest

Log in to DocsForge