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

RFE: NATS same subject subscription not registering handlers #1308

Open
frct1 opened this issue Mar 16, 2024 · 1 comment
Open

RFE: NATS same subject subscription not registering handlers #1308

frct1 opened this issue Mar 16, 2024 · 1 comment
Labels
Core Issues related to core FastStream functionality and affects to all brokers enhancement New feature or request

Comments

@frct1
Copy link

frct1 commented Mar 16, 2024

Describe the bug
In some cases user might need to process same message in multiple handlers, following same as docs code doesn't give documented result.

How to reproduce
Include source code:

from faststream import FastStream, Logger
from faststream.nats import NatsBroker

broker = NatsBroker("nats://127.0.0.1:4222", name="Faststream Client")
app = FastStream(broker)


@broker.subscriber("test-subj-1", "workers")
async def base_handler1(logger: Logger):
    logger.info("base_handler1")


@broker.subscriber("test-subj-1", "workers")
async def base_handler2(logger: Logger):
    logger.info("base_handler2")


@broker.subscriber("test-subj-2", "workers")
async def base_handler3(logger: Logger):
    logger.info("base_handler3")

...

And/Or steps to reproduce the behavior:

  1. Just wrap up basic code from docs

Expected behavior
Handlers are being registered as nats subscribers

Observed behavior
2024-03-17 01:10:43,038 INFO - FastStream app starting...
2024-03-17 01:10:43,041 INFO - workers | test-subj-1 | - BaseHandler1 waiting for messages
2024-03-17 01:10:43,042 INFO - workers | test-subj-2 | - BaseHandler3 waiting for messages

Environment

> faststream -v
Running FastStream 0.4.7 with CPython 3.11.5 on Darwin

Additional context
No additional context

@frct1 frct1 added the bug Something isn't working label Mar 16, 2024
@Lancetnik
Copy link
Collaborator

@frct1 it's not a bug. You can't create consumer on the same subject - this syntax is using to filtering feature

But, this syntax will be deprecated in 0.5.0 in prior to the following one

subscriber = broker.subscriber("test")

@subscriber(filter=filter1)
async def handler1():
    ....

@subscriber(filter=filter2)
async def handler2():
    ....

And, finally, in 0.6.0 I am planning to remove deprecated filter syntax and allow use to create any subscribers he want

But now, please, use multiple interactors in the same handler or create multiple consumer applications

@frct1 frct1 changed the title Bug: NATS same subject subscription not registering handlers RFE: NATS same subject subscription not registering handlers Mar 21, 2024
@Lancetnik Lancetnik removed the bug Something isn't working label Apr 11, 2024
@Lancetnik Lancetnik added enhancement New feature or request Core Issues related to core FastStream functionality and affects to all brokers labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issues related to core FastStream functionality and affects to all brokers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants