Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot work connection_name in client_properties #642

Open
gecheim opened this issue Aug 8, 2024 · 0 comments
Open

Cannot work connection_name in client_properties #642

gecheim opened this issue Aug 8, 2024 · 0 comments

Comments

@gecheim
Copy link

gecheim commented Aug 8, 2024

Based on documentation https://aio-pika.readthedocs.io/en/latest/apidoc.html#aio_pika.connect_robust
My code:

	async def run_client(self):
		self.loop = asyncio.get_running_loop()
		connection = await connect_robust(
			host=self.cfg.host,
			port=self.cfg.port,
			virtualhost=self.cfg.vhost,
			login=self.cfg.user,
			password=self.cfg.password,
			timeout=5,
			client_properties={'connection_name': 'a-adapter'}
		)
		channel = None
		try:
			channel = await connection.channel()
			await channel.set_qos(self.cfg.parallel_task)
			queue = await channel.declare_queue(self.cfg.queue, durable=True)
			await queue.bind(self.cfg.input_exchange, self.cfg.input_route_key)
			self.tag = await queue.consume(self.handle_message, no_ack=False)
			await self.event.wait()
		finally:
			await connection.close()

It not set connection_name on rabbit.

As a result of various attempts to fix this, I received the following version of the code, which sets connection_name on rabbit:

	async def run_client(self):
		self.loop = asyncio.get_running_loop()
		connection = await connect_robust(
			host=self.cfg.host,
			port=self.cfg.port,
			virtualhost=self.cfg.vhost,
			login=self.cfg.user,
			password=self.cfg.password,
			timeout=5,
			client_properties={'name': 'a-adapter'}
		)
		channel = None
		try:
			channel = await connection.channel()
			await channel.set_qos(self.cfg.parallel_task)
			queue = await channel.declare_queue(self.cfg.queue, durable=True)
			await queue.bind(self.cfg.input_exchange, self.cfg.input_route_key)
			self.tag = await queue.consume(self.handle_message, no_ack=False)
			await self.event.wait()
		finally:
			await connection.close()

This is ambiguous. It turns out that to set the connection_name parameter, you need to pass the name parameter to the library. But the documentation says that it is required to pass the connection_name parameter.

Using aio-pika version 9.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant