rabbitmq-c  0.2
C AMQP Client library for RabbitMQ
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
amqp.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <amqp_framing.h>

Go to the source code of this file.

Data Structures

struct  amqp_bytes_t
 Structure for holding a buffer and its size. More...
 
struct  amqp_decimal_t
 For holding a decimal value. More...
 
struct  amqp_table_t
 An AMQP Field Table. More...
 
struct  amqp_array_t
 An AMQP Field Array. More...
 
struct  amqp_field_value_t
 A field table value. More...
 
struct  amqp_table_entry_t
 An entry in a field-table. More...
 
struct  amqp_pool_blocklist_t
 A list of allocation blocks. More...
 
struct  amqp_pool_t
 A memory pool. More...
 
struct  amqp_method_t
 An amqp method. More...
 
struct  amqp_frame_t
 An AMQP frame. More...
 
struct  amqp_rpc_reply_t
 Reply from a RPC method on the broker. More...
 
struct  amqp_connection_info
 Parameters used to connect to the RabbitMQ broker. More...
 

Macros

#define AMQP_EMPTY_BYTES   amqp_empty_bytes
 
#define AMQP_EMPTY_TABLE   amqp_empty_table
 
#define AMQP_EMPTY_ARRAY   amqp_empty_array
 

Typedefs

typedef int amqp_boolean_t
 boolean type
 
typedef uint32_t amqp_method_number_t
 Method number.
 
typedef uint32_t amqp_flags_t
 Bitmask for flags.
 
typedef uint16_t amqp_channel_t
 Channel type.
 
typedef struct
amqp_connection_state_t_ * 
amqp_connection_state_t
 connection state object
 

Enumerations

enum  amqp_field_value_kind_t {
  AMQP_FIELD_KIND_BOOLEAN = 't', AMQP_FIELD_KIND_I8 = 'b', AMQP_FIELD_KIND_U8 = 'B', AMQP_FIELD_KIND_I16 = 's',
  AMQP_FIELD_KIND_U16 = 'u', AMQP_FIELD_KIND_I32 = 'I', AMQP_FIELD_KIND_U32 = 'i', AMQP_FIELD_KIND_I64 = 'l',
  AMQP_FIELD_KIND_U64 = 'L', AMQP_FIELD_KIND_F32 = 'f', AMQP_FIELD_KIND_F64 = 'd', AMQP_FIELD_KIND_DECIMAL = 'D',
  AMQP_FIELD_KIND_UTF8 = 'S', AMQP_FIELD_KIND_ARRAY = 'A', AMQP_FIELD_KIND_TIMESTAMP = 'T', AMQP_FIELD_KIND_TABLE = 'F',
  AMQP_FIELD_KIND_VOID = 'V', AMQP_FIELD_KIND_BYTES = 'x'
}
 Field value types. More...
 
enum  amqp_response_type_enum { AMQP_RESPONSE_NONE = 0, AMQP_RESPONSE_NORMAL, AMQP_RESPONSE_LIBRARY_EXCEPTION, AMQP_RESPONSE_SERVER_EXCEPTION }
 Response type. More...
 
enum  amqp_sasl_method_enum { AMQP_SASL_METHOD_PLAIN = 0 }
 SASL method type. More...
 

Functions

char const * amqp_version (void)
 Gets the version of rabbitmq-c.
 
void init_amqp_pool (amqp_pool_t *pool, size_t pagesize)
 Initializes a amqp_pool_t memory allocation pool.
 
void recycle_amqp_pool (amqp_pool_t *pool)
 Recycles an amqp_pool_t memory allocation pool.
 
void empty_amqp_pool (amqp_pool_t *pool)
 Destroys an amqp_pool_t memory allocation pool.
 
void * amqp_pool_alloc (amqp_pool_t *pool, size_t amount)
 Allocates a block of memory from an amqp_pool_t memory pool.
 
void amqp_pool_alloc_bytes (amqp_pool_t *pool, size_t amount, amqp_bytes_t *output)
 Allocates a block of memory from an amqp_pool_t to an amqp_bytes_t.
 
amqp_bytes_t amqp_cstring_bytes (char const *cstr)
 Wraps a c string in an amqp_bytes_t.
 
amqp_bytes_t amqp_bytes_malloc_dup (amqp_bytes_t src)
 Duplicates an amqp_bytes_t buffer.
 
amqp_bytes_t amqp_bytes_malloc (size_t amount)
 Allocates a amqp_bytes_t buffer.
 
void amqp_bytes_free (amqp_bytes_t bytes)
 Frees an amqp_bytes_t buffer.
 
amqp_connection_state_t amqp_new_connection (void)
 Creates a new amqp_connection_state_t object.
 
int amqp_get_sockfd (amqp_connection_state_t state)
 Gets the sockfd associated with the connection.
 
void amqp_set_sockfd (amqp_connection_state_t state, int sockfd)
 Sets the sockfd associated with the connection.
 
int amqp_tune_connection (amqp_connection_state_t state, int channel_max, int frame_max, int heartbeat)
 Tune various client-side connection parameters.
 
int amqp_get_channel_max (amqp_connection_state_t state)
 Get the maximum number of channels the connection can handle.
 
int amqp_destroy_connection (amqp_connection_state_t state)
 Destroys a connection object.
 
int amqp_handle_input (amqp_connection_state_t state, amqp_bytes_t received_data, amqp_frame_t *decoded_frame)
 Handle input.
 
amqp_boolean_t amqp_release_buffers_ok (amqp_connection_state_t state)
 Check to see if the connection is in a state it can release its internal buffers.
 
void amqp_release_buffers (amqp_connection_state_t state)
 Release connect object internal buffers.
 
void amqp_maybe_release_buffers (amqp_connection_state_t state)
 Release buffers if possible.
 
int amqp_send_frame (amqp_connection_state_t state, amqp_frame_t const *frame)
 Send a frame to the broker.
 
int amqp_table_entry_cmp (void const *entry1, void const *entry2)
 Compare two table entries.
 
int amqp_open_socket (char const *hostname, int portnumber)
 Attempt to open a socket.
 
int amqp_send_header (amqp_connection_state_t state)
 Send AMQP handshake to broker.
 
amqp_boolean_t amqp_frames_enqueued (amqp_connection_state_t state)
 Checks to see if there are any incoming frames ready to be read.
 
int amqp_simple_wait_frame (amqp_connection_state_t state, amqp_frame_t *decoded_frame)
 Waits for a single frame from the broker.
 
int amqp_simple_wait_method (amqp_connection_state_t state, amqp_channel_t expected_channel, amqp_method_number_t expected_method, amqp_method_t *output)
 Waits for a specific method from the broker.
 
int amqp_send_method (amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, void *decoded)
 Sends a method to the broker.
 
amqp_rpc_reply_t amqp_simple_rpc (amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t request_id, amqp_method_number_t *expected_reply_ids, void *decoded_request_method)
 Sends a method to the broker and waits for a method response.
 
void * amqp_simple_rpc_decoded (amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t request_id, amqp_method_number_t reply_id, void *decoded_request_method)
 Sends a method to the broker and waits for a method reponse.
 
amqp_rpc_reply_t amqp_get_rpc_reply (amqp_connection_state_t state)
 Get the last global amqp_rpc_reply.
 
amqp_rpc_reply_t amqp_login (amqp_connection_state_t state, char const *vhost, int channel_max, int frame_max, int heartbeat, amqp_sasl_method_enum sasl_method,...)
 Login to the broker.
 
int amqp_basic_publish (amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_bytes_t routing_key, amqp_boolean_t mandatory, amqp_boolean_t immediate, struct amqp_basic_properties_t_ const *properties, amqp_bytes_t body)
 Publish a message to the broker.
 
amqp_rpc_reply_t amqp_channel_close (amqp_connection_state_t state, amqp_channel_t channel, int code)
 Closes an channel.
 
amqp_rpc_reply_t amqp_connection_close (amqp_connection_state_t state, int code)
 Closes the entire connection.
 
int amqp_basic_ack (amqp_connection_state_t state, amqp_channel_t channel, uint64_t delivery_tag, amqp_boolean_t multiple)
 Acknowledges a message.
 
amqp_rpc_reply_t amqp_basic_get (amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_boolean_t no_ack)
 Do a basic.get.
 
int amqp_basic_reject (amqp_connection_state_t state, amqp_channel_t channel, uint64_t delivery_tag, amqp_boolean_t requeue)
 Do a basic.reject.
 
amqp_boolean_t amqp_data_in_buffer (amqp_connection_state_t state)
 Check to see if there is data left in the receive buffer.
 
char * amqp_error_string (int err)
 Get the error string for the given error code.
 
int amqp_decode_table (amqp_bytes_t encoded, amqp_pool_t *pool, amqp_table_t *output, size_t *offset)
 Deserializes an amqp_table_t from AMQP wireformat.
 
int amqp_encode_table (amqp_bytes_t encoded, amqp_table_t *input, size_t *offset)
 Serializes an amqp_table_t to the AMQP wireformat.
 
void amqp_default_connection_info (struct amqp_connection_info *parsed)
 Initialze an amqp_connection_info to default values.
 
int amqp_parse_url (char *url, struct amqp_connection_info *parsed)
 Parse a connection URL.
 

Variables

const amqp_bytes_t amqp_empty_bytes
 Empty bytes structure.
 
const amqp_table_t amqp_empty_table
 Empty table structure.
 
const amqp_array_t amqp_empty_array
 Empty table array structure.
 

Macro Definition Documentation

#define AMQP_EMPTY_ARRAY   amqp_empty_array
Deprecated:
use amqp_empty_array instead. This is here only for backwards compatibility
#define AMQP_EMPTY_BYTES   amqp_empty_bytes
Deprecated:
use amqp_empty_bytes instead. This is here only for backwards compatibility
#define AMQP_EMPTY_TABLE   amqp_empty_table
Deprecated:
use amqp_emtpy_table instead. This is here only for backwards compatibility

Enumeration Type Documentation

Field value types.

Enumerator:
AMQP_FIELD_KIND_BOOLEAN 

boolean type.

0 = false, 1 = true

See Also
amqp_boolean_t
AMQP_FIELD_KIND_I8 

8-bit signed integer, datatype: int8_t

AMQP_FIELD_KIND_U8 

8-bit unsigned integer, datatype: uint8_t

AMQP_FIELD_KIND_I16 

16-bit signed integer, datatype: int16_t

AMQP_FIELD_KIND_U16 

16-bit unsigned integer, datatype: uint16_t

AMQP_FIELD_KIND_I32 

32-bit signed integer, datatype: int32_t

AMQP_FIELD_KIND_U32 

32-bit unsigned integer, datatype: uint32_t

AMQP_FIELD_KIND_I64 

64-bit signed integer, datatype: int64_t

AMQP_FIELD_KIND_U64 

64-bit unsigned integer, datatype: uint64_t

AMQP_FIELD_KIND_F32 

single-precision floating point value, datatype: float

AMQP_FIELD_KIND_F64 

double-precision floating point value, datatype: double

AMQP_FIELD_KIND_DECIMAL 

amqp-decimal value, datatype: amqp_decimal_t

AMQP_FIELD_KIND_UTF8 

UTF-8 null-terminated character string, datatype: amqp_bytes_t.

AMQP_FIELD_KIND_ARRAY 

field array (repeated values of another datatype.

datatype: amqp_array_t

AMQP_FIELD_KIND_TIMESTAMP 

64-bit timestamp.

datatype uint64_t

AMQP_FIELD_KIND_TABLE 

field table.

encapsulates a table inside a table entry. datatype: amqp_table_t

AMQP_FIELD_KIND_VOID 

empty entry

AMQP_FIELD_KIND_BYTES 

unformatted byte string, datatype: amqp_bytes_t

Response type.

Enumerator:
AMQP_RESPONSE_NONE 

the library got an EOF from the socket

AMQP_RESPONSE_NORMAL 

response normal, the RPC completed successfully

AMQP_RESPONSE_LIBRARY_EXCEPTION 

library error, an error occurred in the library, examine the library_error

AMQP_RESPONSE_SERVER_EXCEPTION 

server exception, the broker returned an error, check replay

SASL method type.

Enumerator:
AMQP_SASL_METHOD_PLAIN 

the PLAIN SASL method for authentication to the broker

Function Documentation

int amqp_basic_ack ( amqp_connection_state_t  state,
amqp_channel_t  channel,
uint64_t  delivery_tag,
amqp_boolean_t  multiple 
)

Acknowledges a message.

Does a basic.ack on a received message

Parameters
[in]statethe connection object
[in]channelthe channel identifier
[in]delivery_tagthe delivery take of the message to be ack'd
[in]multipleif true, ack all messages up to this delivery tag, if false ack only this delivery tag
Returns
0 on success, 0 > on failing to send the ack to the broker. this will not indicate failure if something goes wrong on the broker
amqp_rpc_reply_t amqp_basic_get ( amqp_connection_state_t  state,
amqp_channel_t  channel,
amqp_bytes_t  queue,
amqp_boolean_t  no_ack 
)

Do a basic.get.

Synchonously polls the broker for a message in a queue, and retrieves the message if a message is in the queue.

Parameters
[in]statethe connection object
[in]channelthe channel identifier to use
[in]queuethe queue name to retrieve from
[in]no_ackif true the message is automatically ack'ed if false amqp_basic_ack should be called once the message retrieved has been processed
Returns
amqp_rpc_reply indicating success or failure
int amqp_basic_publish ( amqp_connection_state_t  state,
amqp_channel_t  channel,
amqp_bytes_t  exchange,
amqp_bytes_t  routing_key,
amqp_boolean_t  mandatory,
amqp_boolean_t  immediate,
struct amqp_basic_properties_t_ const *  properties,
amqp_bytes_t  body 
)

Publish a message to the broker.

Parameters
[in]statethe connection object
[in]channelthe channel identifier
[in]exchangethe exchange on the broker to publish to
[in]routing_keythe routing key to use when publishing the message
[in]mandatoryindicate to the broker that the message MUST be routed to a queue. If the broker cannot do this it should respond with a basic.reject method.
[in]immediateindicate to the broker that the message MUST be delivered to a consumer immediately. If the broker cannot do this it should response with a basic.reject method.
[in]propertiesthe properties associated with the message
[in]bodythe message body
Returns
0 on success, 0 > on failure to transmit the message to the broker. since basic.publish is an async method, this return value will not indicate whether the broker encountered an error, such as a non-existant exchange, or a failure in processing due to a mandatory or immediate flag.
int amqp_basic_reject ( amqp_connection_state_t  state,
amqp_channel_t  channel,
uint64_t  delivery_tag,
amqp_boolean_t  requeue 
)

Do a basic.reject.

Actively reject a message that has been delivered

Parameters
[in]statethe connection object
[in]channelthe channel identifier
[in]delivery_tagthe delivery tag of the message to reject
[in]requeueindicate to the broker whether it should requeue the message or just discard it.
Returns
0 on success, 0 > on failing to send the reject method to the broker. This will not indicate failure if something goes wrong on the broker.
void amqp_bytes_free ( amqp_bytes_t  bytes)

Frees an amqp_bytes_t buffer.

Frees a buffer allocated with amqp_bytes_malloc or amqp_bytes_malloc_dup

Calling amqp_bytes_free on buffers not allocated with one of those two functions will result in undefined behavior

Parameters
[in]bytesthe buffer to free
amqp_bytes_t amqp_bytes_malloc ( size_t  amount)

Allocates a amqp_bytes_t buffer.

Creates an amqp_bytes_t buffer of the specified amount

Parameters
[in]amountthe size of the buffer in bytes
Returns
an amqp_bytes_t with amount bytes allocated. output.bytes will be set to NULL on error
amqp_bytes_t amqp_bytes_malloc_dup ( amqp_bytes_t  src)

Duplicates an amqp_bytes_t buffer.

The buffer is cloned and the contents copied.

The memory associated with the output is allocated with amqp_bytes_malloc and should be freed with amqp_bytes_free

Parameters
[in]src
Returns
a clone of the src
amqp_rpc_reply_t amqp_channel_close ( amqp_connection_state_t  state,
amqp_channel_t  channel,
int  code 
)

Closes an channel.

Parameters
[in]statethe connection object
[in]channelthe channel identifier
[in]codethe reason for closing the channel, AMQP_REPLY_SUCCESS is a good default
Returns
amqp_rpc_reply_t indicating success or failure
amqp_rpc_reply_t amqp_connection_close ( amqp_connection_state_t  state,
int  code 
)

Closes the entire connection.

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

Parameters
[in]statethe connection object
[in]codethe reason code for closing the connection. AMQP_REPLY_SUCCESS is a good default.
Returns
amqp_rpc_reply_t indicating the result
amqp_bytes_t amqp_cstring_bytes ( char const *  cstr)

Wraps a c string in an amqp_bytes_t.

Takes a string, calculates its length and creates an amqp_bytes_t that points to it. The string is not duplicated.

For a given input cstr, The amqp_bytes_t output.bytes is the same as cstr, output.len is the length of the string not including the \0 terminator

This function uses strlen() internally so cstr must be properly terminated

Parameters
[in]cstrthe c string to wrap
Returns
an amqp_bytes_t that describes the string
amqp_boolean_t amqp_data_in_buffer ( amqp_connection_state_t  state)

Check to see if there is data left in the receive buffer.

Can be used to see if there is data still in the buffer, if so calling amqp_simple_wait_frame will not immediately enter a blocking read.

Parameters
[in]statethe connection object
Returns
true if there is data in the recieve buffer, false otherwise
int amqp_decode_table ( amqp_bytes_t  encoded,
amqp_pool_t pool,
amqp_table_t output,
size_t *  offset 
)

Deserializes an amqp_table_t from AMQP wireformat.

This is an internal function and is not typically used by client applications

Parameters
[in]encodedthe buffer containing the serialized data
[in]poolmemory pool used to allocate the table entries from
[in]outputthe amqp_table_t structure to fill in. Any existing entries will be erased
[in,out]offsetThe offset into the encoded buffer to start reading the serialized table. It will be updated by this function to end of the table
Returns
0 on success, > 1 on error
void amqp_default_connection_info ( struct amqp_connection_info parsed)

Initialze an amqp_connection_info to default values.

The default values are:

  • user: "guest"
  • password: "guest"
  • host: "localhost"
  • vhost: "/"
  • port: 5672
Parameters
[out]parsedthe connection info to set defaults on
int amqp_destroy_connection ( amqp_connection_state_t  state)

Destroys a connection object.

Destroys a connection object created with amqp_new_connection This function will free all memory and close any sockets associated with the connection

Parameters
[in]statethe connection object
int amqp_encode_table ( amqp_bytes_t  encoded,
amqp_table_t input,
size_t *  offset 
)

Serializes an amqp_table_t to the AMQP wireformat.

This is an internal function and is not typically used by client applications

Parameters
[in]encodedthe buffer where to serialize the table to
[in]inputthe amqp_table_t to serialize
[in,out]offsetThe offset into the encoded buffer to start writing the serialized table. It will be updated by this function to where writing left off
Returns
0 on success, > 1 on error
char* amqp_error_string ( int  err)

Get the error string for the given error code.

The returned string resides on the heap; the caller is responsible for freeing it.

Parameters
[in]errreturn error code
Returns
the error string
amqp_boolean_t amqp_frames_enqueued ( amqp_connection_state_t  state)

Checks to see if there are any incoming frames ready to be read.

If this function returns true, amqp_simple_wait_method will return a new frame without potentially entering a blocking read()

Parameters
[in]statethe connection object
Returns
TRUE if there are frames enqueued, FALSE otherwise
int amqp_get_channel_max ( amqp_connection_state_t  state)

Get the maximum number of channels the connection can handle.

This number can be changed using the amqp_tune_connection function

Parameters
[in]statethe connection object
Returns
the maximum number of channels. 0 if there is no limit
amqp_rpc_reply_t amqp_get_rpc_reply ( amqp_connection_state_t  state)

Get the last global amqp_rpc_reply.

The API methods corresponding to most synchronous AMQP methods return a pointer to the decoded method result. Upon error, they return NULL, and we need some way of discovering what, if anything, went wrong. amqp_get_rpc_reply() returns the most recent amqp_rpc_reply_t instance corresponding to such an API operation for the given connection.

Only use it for operations that do not themselves return amqp_rpc_reply_t; operations that do return amqp_rpc_reply_t generally do NOT update this per-connection-global amqp_rpc_reply_t instance.

Parameters
[in]statethe connection object
Returns
the most recent amqp_rpc_reply_t
int amqp_get_sockfd ( amqp_connection_state_t  state)

Gets the sockfd associated with the connection.

Parameters
[in]statethe connection object
Returns
the sockfd associated with the connection, > 0 if the sockfd has not been set
int amqp_handle_input ( amqp_connection_state_t  state,
amqp_bytes_t  received_data,
amqp_frame_t decoded_frame 
)

Handle input.

For a given input buffer and connection state potentially decode a frame from it

Parameters
[in]statethe connection object
[in]received_dataa buffer of the data to be decoded
[in]decoded_framethe frame
Returns
0 on success, 0 > on error
amqp_rpc_reply_t amqp_login ( amqp_connection_state_t  state,
char const *  vhost,
int  channel_max,
int  frame_max,
int  heartbeat,
amqp_sasl_method_enum  sasl_method,
  ... 
)

Login to the broker.

After using amqp_open_socket and amqp_set_sockfd, call amqp_login to complete connecting to the broker

Parameters
[in]statethe connection object
[in]vhostthe virtual host on the broker. The default virtual host on most brokers is "/"
[in]channel_maxthe maximum number of channels to request of the broker for this connection. 0 means no limit, this is a good default.
[in]frame_maxthe maximum size of an AMQP frame on the wire to request of the broker for this connection. 4096 is the minimum size, 2^31-1 is the maximum, a good default is 131072 (128KB).
[in]heartbeatthe number of seconds between heartbeat frames to request of the broker. A value of 0 disables heartbeats. NOTE: rabbitmq-c does not support heartbeats, your best bet is not to implement this.
[in]sasl_methodthe SASL method to authenticate with the broker. followed by the authentication information. For AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN should be followed by two arguments in this order: const char* username, and const char* password.
Returns
amqp_rpc_reply_t indicating success or failure.
void amqp_maybe_release_buffers ( amqp_connection_state_t  state)

Release buffers if possible.

Releases interal connection buffers if it is possible

Parameters
[in]statethe connection object
amqp_connection_state_t amqp_new_connection ( void  )

Creates a new amqp_connection_state_t object.

amqp_connection_state_t objects created with this function should be freed with amqp_destroy_connection

int amqp_open_socket ( char const *  hostname,
int  portnumber 
)

Attempt to open a socket.

Attempts to open a socket to hostname on portnumber

Parameters
[in]hostnamethis can be a hostname or IP address. Both IPv4 and IPv6 are acceptable
[in]portnumberthe port to connect on. RabbitMQ brokers listen on port 5672, and 5671 for SSL
Returns
the sockfd, or 0 > on error
int amqp_parse_url ( char *  url,
struct amqp_connection_info parsed 
)

Parse a connection URL.

An amqp connection url takes the form:

amqp://[$USERNAME[:$PASSWORD]@]$HOST[:$PORT]/[$VHOST]

Examples: amqp://guest:guest@localhost:5672// amqp://guest:guest@localhost/myvhost

Parameters
[in]urlURI to parse
[out]parsedthe connection info gleaned from the URI
Returns
0 on success, anything else indicates failure
void* amqp_pool_alloc ( amqp_pool_t pool,
size_t  amount 
)

Allocates a block of memory from an amqp_pool_t memory pool.

Parameters
[in]poolthe allocation pool to allocate the memory from
[in]amountthe size of the allocation in bytes
Returns
a pointer to the memory block, or NULL if the allocation cannot be satisified
void amqp_pool_alloc_bytes ( amqp_pool_t pool,
size_t  amount,
amqp_bytes_t output 
)

Allocates a block of memory from an amqp_pool_t to an amqp_bytes_t.

Parameters
[in]poolthe allocation pool to allocate the memory from
[in]amountthe size of the allocation in bytes
[in]outputthe location to store the pointer. On success output.bytes will be set to the beginning of the buffer output.len will be set to amount On error output.bytes will be set to NULL and output.len set to 0
void amqp_release_buffers ( amqp_connection_state_t  state)

Release connect object internal buffers.

Call amqp_release_buffers_ok before calling this to ensure the connection is in a state that it can release the buffers. failing to do this will cause the program to abort.

Parameters
[in]statethe connection object
amqp_boolean_t amqp_release_buffers_ok ( amqp_connection_state_t  state)

Check to see if the connection is in a state it can release its internal buffers.

Call this to check before calling amqp_release_buffers.

Alternatively call amqp_maybe_release_buffers to do this all in one step

Parameters
[in]statethe connection object
Returns
TRUE if the buffers can be released FALSE otherwise
int amqp_send_frame ( amqp_connection_state_t  state,
amqp_frame_t const *  frame 
)

Send a frame to the broker.

Parameters
[in]statethe connection object
[in]framethe frame to send to the broker
Returns
0 on success, 0 > on error
int amqp_send_header ( amqp_connection_state_t  state)

Send AMQP handshake to broker.

Parameters
[in]statethe connection object
Returns
-1 on error, a positive value on success
int amqp_send_method ( amqp_connection_state_t  state,
amqp_channel_t  channel,
amqp_method_number_t  id,
void *  decoded 
)

Sends a method to the broker.

Parameters
[in]statethe connection object
[in]channelthe channel object
[in]idthe method number
[in]decodedthe method object
Returns
0 on success, 0 < on failure
void amqp_set_sockfd ( amqp_connection_state_t  state,
int  sockfd 
)

Sets the sockfd associated with the connection.

Parameters
[in]statethe connection object
[in]sockfdthe socket
amqp_rpc_reply_t amqp_simple_rpc ( amqp_connection_state_t  state,
amqp_channel_t  channel,
amqp_method_number_t  request_id,
amqp_method_number_t expected_reply_ids,
void *  decoded_request_method 
)

Sends a method to the broker and waits for a method response.

Parameters
[in]statethe connection object
[in]channelthe channel object
[in]request_idthe method number of the request
[in]expected_reply_idsa 0 terminated array of expected response method numbers
[in]decoded_request_methodthe method to be sent to the broker
Returns
a amqp_rpc_reply_t which contains the broker response
void* amqp_simple_rpc_decoded ( amqp_connection_state_t  state,
amqp_channel_t  channel,
amqp_method_number_t  request_id,
amqp_method_number_t  reply_id,
void *  decoded_request_method 
)

Sends a method to the broker and waits for a method reponse.

Parameters
[in]statethe connection object
[in]channelthe channel object
[in]request_idthe method number of the request
[in]reply_idthe method number expected in response
[in]decoded_request_methodthe request method
Returns
a pointer to the method, or NULL if an error occurs
int amqp_simple_wait_frame ( amqp_connection_state_t  state,
amqp_frame_t decoded_frame 
)

Waits for a single frame from the broker.

Parameters
[in]statethe connection object
[out]decoded_framethe frame
Returns
0 on success, 0 > on error
int amqp_simple_wait_method ( amqp_connection_state_t  state,
amqp_channel_t  expected_channel,
amqp_method_number_t  expected_method,
amqp_method_t output 
)

Waits for a specific method from the broker.

Waits for a single method on a channel from the broker. If a frame is received that does not match expected_channel or expected_method the program will abort

Parameters
[in]statethe connection object
[in]expected_channelthe channel that the method should be delivered on
[in]expected_methodthe method to wait for
[out]outputthe method
Returns
0 on success, 0 < on failure
int amqp_table_entry_cmp ( void const *  entry1,
void const *  entry2 
)

Compare two table entries.

Works just like strcmp(), comparing two the table keys, datatype, then values

Parameters
[in]entry1the entry on the left
[in]entry2the entry on the right
Returns
0 if entries are equal, 0 < if left is greater, 0 > if right is greater
int amqp_tune_connection ( amqp_connection_state_t  state,
int  channel_max,
int  frame_max,
int  heartbeat 
)

Tune various client-side connection parameters.

Parameters
[in]statethe connection object
[in]channel_maxthe maximum number of channels. The largest this can be is 65535
[in]frame_maxthe maximum size of an frame. The smallest this can be is 4096 The largest this can be is 2147483647 Unless you know what you're doing the recommended size is 131072
[in]heartbeatthe number of seconds between heartbeats NOTE: rabbitmq-c does not support heartbeats, setting this will not have any effect
Returns
0 on success, anything else indicates error
char const* amqp_version ( void  )

Gets the version of rabbitmq-c.

Returns
string representation of the library. Statically allocated, does not need to be freed
void empty_amqp_pool ( amqp_pool_t pool)

Destroys an amqp_pool_t memory allocation pool.

This is a frees all memory associated with an amqp_pool_t

Parameters
[in]poolthe amqp_pool_t to empty
void init_amqp_pool ( amqp_pool_t pool,
size_t  pagesize 
)

Initializes a amqp_pool_t memory allocation pool.

Readies an allocation pool for use. An amqp_pool_t must be initialized before use

Parameters
[in]poolthe amqp_pool_t structure to initialize. Calling this function on a pool a pool that has already been initialized will result in undefined behavior
[in]pagesizethe unit size that the pool will allocate memory chunks in. Anything allocated against the pool with a requested size will be carved out of a block this size. Allocations larger than this will be allocated individually
void recycle_amqp_pool ( amqp_pool_t pool)

Recycles an amqp_pool_t memory allocation pool.

Recycles the space allocate by the pool

This invalidates all allocations made against the pool before the call was made. Use of those pointers will have undefined behavior.

Note: this may or may not release memory, if you're looking to free memory try using empty_amqp_pool

Parameters
[in]poolthe amqp_pool_t to recycle