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

Why I can not only close channel? #659

Open
huanhuang opened this issue Dec 10, 2024 · 0 comments
Open

Why I can not only close channel? #659

huanhuang opened this issue Dec 10, 2024 · 0 comments

Comments

@huanhuang
Copy link

I want close channel when I published a message, I call channel.close() ,but channel didn't closed even if I call the channel.is_closed() returned True. Through the RabbitMQ Manager, I still see the channel. if I publish multi message, it will reached max channel number, then raise exception. but I don't know how to close channel if I had published a msg.Following is example code:

routing_key = "test_queue"
msg_id = 0
while True:
    channel: aio_pika.abc.AbstractChannel = await connection.channel()
    await channel.declare_queue(routing_key, durable=True)
    print(channel.number)
    exchange = channel.default_exchange
    await exchange.publish(
        aio_pika.Message(
            body='Hello {}'.format(msg_id).encode(), delivery_mode=aio_pika.DeliveryMode.PERSISTENT
        ),
        routing_key=routing_key,
        timeout=10
    )
    await channel.close()
    await asyncio.sleep(0.1)
    msg_id += 1
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