Closed kongxa closed 1 year ago
Does amqp_channel_open and amqp_channel_close need called in every operation, likes in amqp_exchange_declare, amqp_queue_declare, amqp_queue_bind, amqp_queue_unbind, amqp_queue_delete,amqp_basic_publish,amqp_basic_consume?
amqp_exchange_declare (and friends) need an open channel, that channel may be reused between different calls, so there is no reason to close the channel after each call. A channel may be closed by the server if one of those calls fails. If the server indicates that the channel is closed, you'll need to open a new channel before calling any new functions that require a channel.
Does amqp_basic_publish have rpc reply from rabbitmq server? I am not find in example
By default amqp_basic_publish does not get an rpc-reply from the server. You can enable publisher confirms, in which the server will send a basic.ack method when back to the client after it has successfully processed a message. https://github.com/alanxz/rabbitmq-c/blob/master/examples/amqp_producer.c has a small example where publisher confirms are not enabled
If amqp_queue_bind return NULL,i find two proccess, below . Does amqp_get_rpc_reply realy get something from rabbitmq server when amqp_queue_bind returns NULL?
If amqp_queue_bind returns NULL, you will need to use amqp_get_rpc_reply to understand why it failed, this may be due to the server returning an error.
Thank you very much.
By default amqp_basic_publish does not get an rpc-reply from the server. You can enable publisher confirms, in which the server will send a basic.ack method when back to the client after it has successfully processed a message. https://github.com/alanxz/rabbitmq-c/blob/master/examples/amqp_producer.c has a small example where publisher confirms are not enabled
If publisher confirms are not enabled, amqp_basic_publish does not get an rpc-reply from the server, amqp_get_rpc_reply was called anyway. Will the process be blocked by this call?
If amqp_queue_bind returns NULL, you will need to use amqp_get_rpc_reply to understand why it failed, this may be due to the server returning an error.
If amqp_queue_bind return success, do i need to call amqp_get_rpc_reply? I have known the result, but if i no need to call amqp_get_rpc_reply,will some rpc reply be left in rabbitmq client or connection?
If amqp_queue_bind return success, do i need to call amqp_get_rpc_reply?
No, you only need to call it when amqp_queue_bind returns NULL.
rabbitmq version:v0.10.0 When i implement rabbitmq client,i see this instance below https://blog.csdn.net/LT_lover/article/details/80915711
Here is my question:
amqp_queue_bind(conn, 1, amqp_cstring_bytes(queue), amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding");
2)if (!amqp_queue_bind(conn, 1, queue_bytes, eb, cstring_bytes(routing_key_token), amqp_empty_table)) { die_rpc(amqp_get_rpc_reply(conn), "queue.bind"); }
Code: