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

Bug: RabbitMQ Broker's Connection #1954

Open
Wintreist opened this issue Dec 2, 2024 · 0 comments · May be fixed by #1779
Open

Bug: RabbitMQ Broker's Connection #1954

Wintreist opened this issue Dec 2, 2024 · 0 comments · May be fixed by #1779
Labels
bug Something isn't working

Comments

@Wintreist
Copy link

Describe the bug
If you create a broker. Connect and then create publisher, an error occurs when trying to send a message

How to reproduce
Include source code:

from faststream.rabbit import RabbitBroker, RabbitQueue

artifact_download = RabbitQueue("artifact_download", True)

async def register_download_artifact(artifact):
    broker = RabbitBroker(url="")
    await broker.connect()
    publisher = broker.publisher(artifact_download)
    await publisher.publish(
        message=artifact,
        persist=True,
    )

Expected behavior
I expect that the message has been sent

Observed behavior

  File "/app/build_downloader/server/api_v1/artifacts/dependencies.py", line 173, in register_download_artifact
    await publisher.publish(
  File "/usr/local/lib/python3.12/site-packages/faststream/rabbit/publisher/usecase.py", line 258, in publish
    assert self._producer, NOT_CONNECTED_YET  # nosec B101
           ^^^^^^^^^^^^^^
AssertionError: Please, `connect()` the broker first.

The problem is solved if you connect the broker after creating publisher, and not before creating

broker = RabbitBroker(url="")
publisher = broker.publisher(artifact_download)
await broker.connect()

but then the error message is wrong: Please, connect() the broker first.

Environment
Running FastStream 0.5.30 with CPython 3.12.3 on Linux

@Wintreist Wintreist added the bug Something isn't working label Dec 2, 2024
@Wintreist Wintreist changed the title Bug: Broker's Connection Bug: RabbitMQ Broker's Connection Dec 2, 2024
@Lancetnik Lancetnik linked a pull request Dec 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant