rabbiitmq non-blocking calls

https://blog.csdn.net/panxianzhan/article/details/50755409

 

https://blog.csdn.net/u013946356/article/details/82420489?utm_source=blogxgwz0

Recent project uses rabbit, the client uses rabbitmq-c library, the number of Chinese online no explanation, so the use of the function summarized:

amqp_new_connection

Function operates: allocates and initializes a new connection object amqp

The function prototype: amqp_connection_state_t amqp_new_connection (void);

Parameters: None

Return value: the successful return amqp connection object, failed to return NULL

amqp_tcp_socket_new

Function role: to create tcp socket

函数原型:amqp_socket_t * amqp_tcp_socket_new(amqp_connection_state_t state);

Parameters: amqp connection object

Return value: the successful return tcpsocket, failed to return NULL

amqp_socket_open_noblock

Function operates: nonblocking open socket connection

函数原型:int  amqp_socket_open_noblock(amqp_socket_t *self, const char *host,int port, struct timeval *timeout);

Parameters: self socket socket

 host ip

   port port

   timeout connection timeout

Returns: 0 on success, non-zero failure

 

amqp_login

Function role: Login rabbitmq

函数原型: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, ...);

Parameters: state amqp connection object

                vhost virtual host

                channel_max channel maximum number of connections, 0 for no limit

frame_max client communication and maximum allowed frame size. The default value is 131072, increase this help increase throughput, reduce delay helps reduce the value

                    heartbeat heartbeat interval, the heartbeat 0 off, only support part of the functions of the heart

sasl_method authentication MQP_SASL_METHOD_PLAIN: with two parameters const char * username, and const char * password.AMQP_SASL_METHOD_EXTERNAL: const with the parameter char * identity.

Returns: the results

 

amqp_channel_open

Function operates: channel open connection

函数原型:amqp_channel_open_ok_t *amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel);

Parameters: state amqp connection object

     channel connecting channel

Return value: channel_id

amqp_exchange_declare

Function role: Declare exchange

函数原型:amqp_exchange_declare_ok_t *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);

Parameters: state amqp connection object

     channel connecting channel

     exchange switch

     type switch type fanout direct broadcast direct binding theme topic fuzzy match

     If 1 passive, but did not exist before the switch, it will return a failure

     durable 1 0 persistent non-persistent

     After the exchange is not binding auto_delete 1 0 queue does not remove deleted

     internal 0 1 can be used directly can not be used directly, use only bind to other exchange

     arguments extended parameters

Return value: channel_id

amqp_queue_declare

Function role: statement queue

函数原型:amqp_queue_declare_ok_t *AMQP_CALLamqp_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);

Parameters: state amqp connection object

     channel connecting channel

     queue queue

     If 1 passive, but did not exist before the queue, it will return a failure

     durable 1 0 persistent non-persistent

When the connection is not exclusive 1 the current time, the current queue 0 connection is not automatically delete the queue is not automatically deleted

1 when no auto_delete consumer, the queue 0 is automatically deleted without consumer, the queue is not automatically deleted

Return value: channel_id

amqp_queue_bind

Function operates: Binding switch queues and

函数原型:amqp_queue_bind_ok_t *AMQP_CALL amqp_queue_bind(amqp_connection_s           tate_t state, amqp_channel_t channel, amqp_bytes_t queue,amqp_bytes_t exch     ange, amqp_bytes_t routing_key, amqp_table_t arguments);

Parameters: state amqp connection object

     channel connecting channel

     queue queue

     exchange switch

     routing_key route

     arguments extended parameters

Return value: channel_id

amqp_basic_publish

Function role: dissemination of information

函数原型: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,structamqp_basic_properties_t_ const *properties, amqp_bytes_t body);

Parameters: state amqp connection object

     channel connecting channel

     exchange switch

     routing_key route

     mandatory 1 message must be routed to the queue that is otherwise fail

     immediate 1 If the message does not subscribe, return failure

     properties properties

     message body member

Return Value: success

amqp_basic_consume

Function role: the beginning of a queue consumer

函数原型:amqp_basic_consume_ok_t * amqp_basic_consume(amqp_connection_statet state, amqp_channel_t channel, amqp_bytes_t queue, amqp_bytes_t consumer_tag, amqp_boolean_t no_local, amqp_boolean_t no_ack, amqp_boolean_t exclusive, amqp_table_t arguments);

Parameters: state amqp connection object

     channel connecting channel

     queue queue

     consumer_tag consumer identity  

     no_local 1 does not receive the reception 0

     no_ack 1 no reply 0 recovery

         When the connection is not exclusive 1 the current time, the current queue 0 connection is not automatically delete the queue is not automatically deleted

     arguments extended parameters

Returns: result

amqp_consume_message

Function role: receiving a message

函数原型:amqp_rpc_reply_t amqp_consume_message(amqp_connection_state_t state, amqp_envelope_t *envelope, struct timeval *timeout, int flags);

Parameters: state amqp connection object

     packet envelope

     timeout timeout reception

     flags retention value 0

Returns: result

amqp_channel_close

Function action: Close Channel

函数原型:amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state,

amqp_channel_t channel, int code);

Parameters: state amqp connection object

     channel connecting channel

     code closed type, default AMQP_REPLY_SUCCESS

Returns: Close results

amqp_destroy_envelope

Function role: the destruction of a message packet

Function prototype: void amqp_destroy_envelope (amqp_envelope_t * envelope)

Parameters: envelope packet

Return Value: None

amqp_connection_close

Function action: Close connection

函数原型:amqp_rpc_reply_t  amqp_connection_close(amqp_connection_state_t state, int code);

Parameters: state amqp connection object

code closed type, default AMQP_REPLY_SUCCESS

Returns: Close results

amqp_destroy_connection

Function role: the destruction of the connection object

函数原型:int amqp_destroy_connection(amqp_connection_state_t state);

Parameters: state amqp connection object

Return Value: Close Results
 
Original: https: //blog.csdn.net/u013946356/article/details/82420489
 

Guess you like

Origin www.cnblogs.com/hshy/p/11058699.html