Re: RabbitMQ-C : Specify user-friendly Connection Name

164 views
Skip to first unread message

Alan Antonuk

unread,
Sep 28, 2020, 12:30:27 PM9/28/20
to Dzhumabaev, Nursultan, rabbitmq-c-users


On Mon, Sep 28, 2020 at 6:30 AM Dzhumabaev, Nursultan <dzhuma...@auca.kg> wrote:
Hello Alan!

I am a Senior student at the Software Engineering department and currently an intern programmer in C++. I do have some questions, can you please answer them for me? :D
1. When the connection is forcibly closed via the RabbitMQ web interface, we can specify the reason for that in a special window. I tried to figure out where the reason is saved in code, and it's for some reason here : ((char*)conn->pool_table[0]->pool.alloc_block+14). Q: Is there any easier way to get the message?†

Yes, depending on what call errors out, you'll want to look at the last `amqp_rpc_reply_t` specifically looking at the method member. You'll need to look at the id field, and validate that its a AMQP_CONNECTION_CLOSE_METHOD, then decoded can be cast to an amqp_connection_close_t, some functions return this directly, for others you'll want to use the amqp_get_rpc_reply function to get this information.
 
2. And I did my best in looking for the "?" mark, but did not find that. Q: Where Can I specify the name for the Connection? For this moment, it's only a question "?" mark (in the RabbitMQ web interface).

 This can be specified by adding a `connection_name` item with your desired name (as a string) to the properties table when calling `amqp_login_with_properties`.


Thank you!

Sincerely,
Dzhumabaev Nursultan

Alan Antonuk

unread,
Sep 29, 2020, 1:26:32 PM9/29/20
to Dzhumabaev, Nursultan, rabbitmq-c-users
+rabbitmq-c-users (please respond to the list so that others may learn here as well).

On Tue, Sep 29, 2020 at 2:45 AM Dzhumabaev, Nursultan <dzhuma...@auca.kg> wrote:
Alan! Regarding the second question, haha, you gave me the exact solution, but I by mistake also sent \0000 at the end of char* to RabbitMQ. I inspected the API and noticed that! So, yeah, the second question now is irrelevant and solved! Thank you!

Great, glad you were able to figure it out.
 

Sincerely,
Dzhumabaev Nursultan

On Tue, Sep 29, 2020 at 2:59 PM Dzhumabaev, Nursultan <dzhuma...@auca.kg> wrote:
Hello Alan,

Thank you for your response!
1. I am using the code from your examples, specifically amqp_listen.c. I am connected to RabbitMQ and then I forcefully via Web Interface close the connection. After that, res = amqp_consume_message(conn, &envelope, NULL, 0);  res.reply_type equals to AMQP_RESPONSE_LIBRARY_EXCEPTION. And method member id is 0 and decoded also 0x0000000000000000. So I can not really cast that to  amqp_connection_close_t. Why is it so?

When amqp_rpc_reply_t.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION, then you need to examine the library_error member instead of the reply member (see documentation: https://github.com/alanxz/rabbitmq-c/blob/master/librabbitmq/amqp.h#L646-L669, library_error will be one of the amqp_status_enum values).
 
2. Yes, I followed your steps and now I can see among Client Properties the field connection_name and it's value. But In the connections, the name is still question"?" mark.
image.png but on the connections page 
image.png
It seems that for this specific name there is a special field Client-provided name. Is there any way we can pass a name there? For example this connection was created in .NET Core, they do have such an option. And it's name in connections page can be seen. 
image.png
image.png

Thank you!

Sincerely,
Dzhumabaev Nursultan
Reply all
Reply to author
Forward
0 new messages