# RabbitMQ — migrat pe clusterul RAG (2026-04-22) > **TL;DR**: DIDI folosește **clusterul RabbitMQ RAG** (3 noduri 3.13 + HAProxy VIP). Containerul local `staging-dataLayer-rabbitmq` din `data-layer/docker-compose.yml` e **oprit dar păstrat** ca fallback rapid. Conexiunea e centralizată via `agent-v3/src/queue/connection.ts`. --- ## Ce era aici (legacy) `staging-dataLayer-rabbitmq` — un container RabbitMQ 3.12.6 management standalone pe `didi-network` Docker. Single-node, fără mirroring, vhost `/`. Topologie creată dinamic la startup workerilor. ## Ce e acum ### Cluster RabbitMQ RAG (producție) | Nod | Hostname | IP | AMQP | Mgmt UI | |---|---|---|---|---| | rag01 (HAProxy VIP) | `rag01` | `10.11.50.100` | 16672 (VIP), 5672 direct | 16673 (VIP), 15672 direct | | rag02 | `rag02` | `10.11.50.102` | 5672 | 15672 | | rag03 | `rag03` | `10.11.50.103` | 5672 | 15672 | **Endpoint-uri pentru aplicații:** | Scop | Endpoint | |---|---| | **AMQP VIP** (publish + consume) | `10.11.50.100:16672` | | **Management UI** | `http://10.11.50.100:16673` (admin/``) | | HAProxy stats | `http://10.11.50.100:8404/stats` | Vhost DIDI: `/didi` (izolare totală — alte vhost-uri (`notify`, `/hassio`) nu se văd). User: `didi` cu permisiuni full pe `/didi`. Parolă în `vault-ul de credențiale` `name='DIDI Platform RabbitMQ'`. URL AMQP în cod: `amqp://didi:@10.11.50.100:16672/%2Fdidi` (slash URL-encoded ca `%2F`). ### Conexiune centralizată în cod `agent-v3/src/queue/connection.ts` — manager unic ioredis-style cu lazy initialization, două canale (regular consume + confirm publish), auto-recovery la 2s pentru failover HA, graceful shutdown pe SIGTERM/SIGINT. `agent-v3/src/shared/queue/constants.ts` — topologie cozi (exchange, routing keys, prioritați). ## Topologie cozi (creată dinamic de workeri la startup) ### Exchange | Nume | Tip | Durabil | |---|---|---| | `analysis` | topic | da | ### Cozi componente (24 = 4 componente × 6 plan types) ``` analysis.techniques.{1..6} analysis.ai_tampered.{1..6} analysis.claims.{1..6} analysis.domain.{1..6} ``` Fiecare cu max-priority=10, dead-letter exchange, message TTL 24h. ### Coadă agregare `analysis.results` (fan-in) cu bindings de la fiecare componentă. ### Prioritați per plan | Plan Type | Prioritate | Tip | |---|---|---| | 1 | 1 | freemium | | 2 | 2 | starter | | 3 | 4 | basic | | 4 | 6 | pro | | 5 | 8 | business | | 6 | 10 | enterprise | ## Containerul local `staging-dataLayer-rabbitmq` Definit în `data-layer/docker-compose.yml`, configurat să pornească dar **manual oprit** ca parte din migrare. Volumul `didi-staging-rabbitmq-data` e intact. Status curent: `Exited`. ### De ce e păstrat? Fallback rapid dacă cluster RAG e indisponibil. Pentru reactivare temporară: ```bash backend/services/orchestration-layer/scripts/redis-switch.sh local rabbit # (același script gestionează rabbit + redis) ``` ## Switch rapid cluster ↔ local ```bash # Folosește local ./redis-switch.sh local rabbit # Cluster (default) ./redis-switch.sh cluster rabbit # Both ./redis-switch.sh cluster both # Status ./redis-switch.sh status both ``` ## Verificare cluster ```bash # Mgmt UI (browser) http://10.11.50.100:16673 # admin/ # Quick test prin rabbitmqctl pe nod cluster ssh admin365@10.11.50.102 sudo rabbitmqctl status sudo rabbitmqctl list_vhosts sudo rabbitmqctl list_queues -p /didi name messages consumers # Via HTTP API curl -s -u admin: http://10.11.50.100:16673/api/overview | python3 -m json.tool ``` ## Workerii (în `agent-v3` docker-compose) Servicii Docker care consumă din cluster: | Worker | Replici | Coadă | |---|---|---| | `worker-techniques` | 2 | `analysis.techniques.1-6` | | `worker-ai-tampered` | 2 | `analysis.ai_tampered.1-6` | | `worker-claims` | 3 | `analysis.claims.1-6` (mai multe replici, mai lent) | | `worker-domain` | 2 | `analysis.domain.1-6` | | `worker-media-preprocess` | 2 | `analysis.media_preprocess.*` | | `verdict-aggregator` | 2 | `analysis.results` | ## Verificări dispatcher Script verificare cluster ready: `agent-v3/scripts/verify-rabbitmq-cluster.ts` — testează conectivitate, vhost privileges, topology, în funcție de user `didi` și endpoint VIP. ## Linkuri rapide - Ghid utilizare cluster: `landingzone/rabbitmq-rag/README.md` (repo `git.finesynergy.eu/lucian/landingzone`) - Onboarding vhost nou: `landingzone/rabbitmq-rag/CLAUDE_PROMPT.md` - Mgmt UI: `http://10.11.50.100:16673` ## Status - ✅ Migrare aplicată: 2026-04-22 - ✅ Vhost `/didi` izolat, user `didi` cu permisiuni minime - ✅ Container local păstrat ca fallback (oprit, volum intact) - ✅ Topologie creată dinamic la startup (24 cozi + results + DLQ) - ✅ Workerii (în agent-v3) consumă cu prefetch ajustat per componentă