Reputation: 4078
I am working with an AI chat agent system in node js and typescript. The system currently processes requests for the agents in memory as part of the request thread, and streams responses back via socket io. This setup is less than ideal, and we want to improve it. The goal is to move the processing of requests to backrgound jobs with rabbit mq consumers, but we want to still be able to stream from the consumers to the frontend via websocket interface. What is the best high level architecture to stream from a rabbit mq consumer to a websocket frontend?
What I am considering right now is setting up https://github.com/cloudamqp/amqp-client.js and pushing the responses to a queue that is then consumed by the web browser. The problem is that I'm not sure how to set up the connection tracking so that only the results from a particular agent are sent back to the browser. Is there a better architecture I could use?
Maybe something like setting up a websocket entpoint that is itself a consumer for the output from the worker queue that handles disseminating the messages/preserving logs/writing to db?
Upvotes: -1
Views: 30