Skip to content

Commit 1225b69

Browse files
committed
ensure client friendly name in rabbit UI
1 parent 8ee69a5 commit 1225b69

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/service-library/src/servicelib/rabbitmq/_client_rpc.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ async def create(
3232
cls, *, client_name: str, settings: RabbitSettings, **kwargs
3333
) -> "RabbitMQRPCClient":
3434
client = cls(client_name=client_name, settings=settings, **kwargs)
35-
await client._rpc_initialize() # noqa: SLF001
35+
await client._rpc_initialize()
3636
return client
3737

3838
async def _rpc_initialize(self) -> None:
39+
# NOTE: to show the connection name in the rabbitMQ UI see there
40+
# https://www.bountysource.com/issues/89342433-setting-custom-connection-name-via-client_properties-doesn-t-work-when-connecting-using-an-amqp-url
41+
#
42+
connection_name = f"{get_rabbitmq_client_unique_name(self.client_name)}.rpc"
43+
url = f"{self.settings.dsn}?name={connection_name}"
3944
self._connection = await aio_pika.connect_robust(
40-
self.settings.dsn,
41-
client_properties={
42-
"connection_name": f"{get_rabbitmq_client_unique_name(self.client_name)}.rpc"
43-
},
45+
url,
46+
client_properties={"connection_name": connection_name},
4447
)
4548
self._channel = await self._connection.channel()
4649

0 commit comments

Comments
 (0)