gmr / rabbitpy

A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
http://rabbitpy.readthedocs.org
BSD 3-Clause "New" or "Revised" License
242 stars 58 forks source link

Identify connections #106

Open alexlep opened 7 years ago

alexlep commented 7 years ago

Hi,

Actually I have the same question which is described here, for example.

I'd like to identify each separate connection from remote hosts, and in my code several connections from one IP address are possible, so identifying by IP won't do the trick.

It's possible to pass client internal parameters (like it's described in provided link), but in current rabbitpy implementation it's not possible to pass some custom client params to Connection. Please correct me if I'm wrong.

In rabbitpy client parameters are defined in channel0, method _build_start_ok_frame. Maybe it's possible to add some connection_id(some randomly generated value) parameter to parameters dictionary? Then this parameter will be present in clients properties, and it will be possible to identify connection id, by means of RabbitMQ WebApi(/api/connections):

{ "auth_mechanism": "PLAIN", "channels": 1, "client_properties": { "capabilities": { "authentication_failure_close": true, "basic.nack": true, "connection.blocked": true, "consumer_cancel_notify": true, "publisher_confirms": true }, "information": "See https://rabbitpy.readthedocs.io", "platform": "Python 2.7.6", "product": "rabbitpy", "version": "1.0.0" },

Thanks, Alex