Add and remove subscribers at runtime #2527
|
Hi, I have an application that consumes differents redis sources in order to manage calls. 1 redis stream is receiving start_call and stop_call events For each call, I need to start a new subscriber, as each call events will be pushed to a specific redis list. Today, I buit something working: It works. But, I'm under the impression that it's not optimal. I would prefer to have a single faststream app, with one main subscriber available from start, and subscribers per call added on demand, and removed when the call finishes. Questions:
Thank you, |
Replies: 6 comments 3 replies
|
@pbonneaudiabolocom hi! Did you check dynamic subscribers documentation section? It looks like a feature for your case |
|
Hi, Thank you for your answer. I tried that approach, but it does't seem present on 5.0 yet. On RC4, I ended up having plenty of issues with the event parsing to get my pydantic object as before. I'll wait until the situation is stabilized with the Message management before moving to that new solution. Regards, |
|
OK, after investigating the bug, I found out that it's because I'm using JSONFormat, which is not default comportment anymore. Question would be... how are we supposed to transform subscriber message to pydantic one ? I trued something like that... but no luck. |
|
in the meantime, I did that: |
|
Hi, I'm trying to use these subscribers now that 0.6 is live. I don't know if the documentation is up to date, but it doesn't seem to work for me. But I don't really understand from the example how you are supposed to make it work. The documentation says, in a nutshell.
But in the end, I don't see how it could integrate with a queueing mechanism. in my case I: In parralel, I'm expecting the subscriber to execute some code for each message until I stop it. Somehow, I'm trying to reproduce the handler mechanism that I have with a classic fast stream app where you declare it and it will manage itself properly. Doesn't make much sence for me from the doc how I'm supposed to arrive somewhere with dynamic subscriber. Any hint ? Regards, |
|
Ok, found it: It's working as expected. |
Ok, found it:
It's working as expected.