AiCPlayer
Interface of aic vm - for rendering aspect, sensors, video records
Macros | Functions
amqp_listen.c File Reference

Listen on AMQP queues and consume messages. More...

#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include "logger.h"
#include "config_env.h"
#include "amqp_listen.h"
#include <amqp.h>
#include <amqp_framing.h>
#include <amqp_tcp_socket.h>
Include dependency graph for amqp_listen.c:

Go to the source code of this file.

Macros

#define LOG_TAG   "amqp_listen"
 
#define RETRY
 

Functions

int amqp_listen_retry (const char *hostname, int port, const char *bindingkey, amqp_connection_state_t *conn, const unsigned int tries)
 Setup a consumer for a specific queue. More...
 
int amqp_consume (amqp_connection_state_t *conn, amqp_envelope_t *envelope)
 Consume one message from a connection object. More...
 

Detailed Description

Listen on AMQP queues and consume messages.

Definition in file amqp_listen.c.

Macro Definition Documentation

#define LOG_TAG   "amqp_listen"

Definition at line 15 of file amqp_listen.c.

#define RETRY
Value:
do \
{ \
sleep(backoff); \
backoff *= 2; \
current_try++; \
} while (0)

Function Documentation

int amqp_consume ( amqp_connection_state_t *  conn,
amqp_envelope_t *  envelope 
)

Consume one message from a connection object.

Parameters
connThe connection object to use
envelopea preallocated envelope to store the message
Returns
-1 on failure
0 on success

Definition at line 90 of file amqp_listen.c.

Here is the caller graph for this function:

int amqp_listen_retry ( const char *  hostname,
int  port,
const char *  bindingkey,
amqp_connection_state_t *  conn,
const unsigned int  tries 
)

Setup a consumer for a specific queue.

Parameters
hostnameThe host of the RabbitMQ server
portThe port of the RabbitMQ server
bindingkeythe queue
connthe connection object to initialize
triesthe number of tries

This function will try to connect tries number of times, with a doubled delay everytimes something fails in the setup. In case of failure, it will log an error and terminate the program.

Definition at line 17 of file amqp_listen.c.

Here is the call graph for this function:

Here is the caller graph for this function: