How I used RabbitMQ and local LLMs to handle procedural world-generation and an emerging economy in my indie RPG
Hey everyone,
I’m currently single-handedly developing Homeris, a custom MUD (text-based RPG) engine written in Java with a PostgreSQL vector database. The entire game world, room descriptions, and NPC backgrounds are dynamically generated and enriched on the fly using a local Meta-Llama-3.1-8B-Instruct-GGUF (Q5_K_M) running on a local mini-PC.
Up until last week, whenever the game engine needed the local LLM to rewrite a room description based on the kingdom's shifting economic state, it relied on standard async threads (CompletableFuture).
It worked, but it was a disaster waiting to happen. Blasting a local 8B model with dozens of concurrent requests completely melted my RAM, caused frequent API timeouts, and if the server crashed mid-generation, those world-building tasks were just lost in limbo.
Enter RabbitMQ.
I completely refactored the AI pipeline into a strict Producer-Consumer pattern using RabbitMQ.
- Resilience: The game engine now safely dumps world-generation and character-enrichment tasks into a persistent queue. If I need to reboot the server or if something crashes, the queue doesn't care—the tasks sit safely in RabbitMQ and pick up exactly where they left off upon restart.
- Rate Limiting: The consumer fetches tasks via a strict rate-limit (
basicQos(1)), feeding them to the local RAG module one single prompt at a time. No more resource starvation.
The Monthly World Shift: I hooked this whole message pipeline straight into my EconomyManager. Every game-month, the engine checks the health and wealth of each simulated kingdom. If a region decays into poverty, its rooms are quietly queued up. RabbitMQ passes them to the LLM, which dynamically rewrites the descriptions on the fly—adding visual cues like peeling plaster, rotting wood, and extinguished torches. If the kingdom recovers, the text shifts back to luxury.
Umanizing the Agents: To make the text-based environment feel alive, I also built a few features to make the NPCs mimic actual human players in chat:
- NpcTypoGenerator: NPCs now occasionally fat-finger words based on their state (e.g., typing "helli" instead of "hello") and immediately fire a correction in the next line (*hello).
- SimulateAfkAction: If an NPC is exhausted or lacks stimulation, they flag themselves as AFK, freeze their utility brain, and will hit you with a quick "brb" if you try to talk to them.
Would love to hear your thoughts on this architecture, especially if anyone else is orchestrating message brokers with local GGUF models for dynamic agent simulation!