feat: WebSocket temps réel + Finance Workflow + corrections
- Task #6: WebSocket /ws/dashboard + Kafka events (5 topics) * Backend: KafkaEventProducer, KafkaEventConsumer * Mobile: WebSocketService (reconnection, heartbeat, typed events) * DashboardBloc: Auto-refresh depuis WebSocket events - Finance Workflow: approbations + budgets (backend + mobile) * Backend: entities, services, resources, migrations Flyway V6 * Mobile: features finance_workflow complète avec BLoC - Corrections DI: interfaces IRepository partout * IProfileRepository, IOrganizationRepository, IMembreRepository * GetIt configuré avec @injectable - Spec-Kit: constitution + templates mis à jour * .specify/memory/constitution.md enrichie * Templates agent, plan, spec, tasks, checklist - Nettoyage: fichiers temporaires supprimés Signed-off-by: lions dev Team
This commit is contained in:
155
unionflow/scripts/kafka/README.md
Normal file
155
unionflow/scripts/kafka/README.md
Normal file
@@ -0,0 +1,155 @@
|
||||
# Scripts Kafka pour UnionFlow
|
||||
|
||||
## Problème résolu
|
||||
|
||||
Les erreurs `UNKNOWN_TOPIC_OR_PARTITION` apparaissent car **les topics Kafka n'existent pas encore**.
|
||||
|
||||
Ton Kafka actuel (conteneur `kafka` sur port 9092) fonctionne parfaitement. Il faut juste créer les 5 topics.
|
||||
|
||||
---
|
||||
|
||||
## ✅ Solution : Créer les Topics
|
||||
|
||||
### Option 1 : Exécuter le script (Recommandé)
|
||||
|
||||
#### Windows (PowerShell ou CMD)
|
||||
|
||||
```cmd
|
||||
cd C:\Users\dadyo\PersonalProjects\lions-workspace\unionflow\scripts\kafka
|
||||
create-topics.bat
|
||||
```
|
||||
|
||||
#### Linux/Mac
|
||||
|
||||
```bash
|
||||
cd /path/to/unionflow/scripts/kafka
|
||||
chmod +x create-topics.sh
|
||||
./create-topics.sh
|
||||
```
|
||||
|
||||
### Option 2 : Commandes manuelles (si le script échoue)
|
||||
|
||||
Copie-colle ces commandes une par une dans PowerShell/CMD :
|
||||
|
||||
```cmd
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --create --topic unionflow.finance.approvals --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1 --if-not-exists
|
||||
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --create --topic unionflow.dashboard.stats --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1 --if-not-exists
|
||||
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --create --topic unionflow.notifications.user --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1 --if-not-exists
|
||||
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --create --topic unionflow.members.events --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1 --if-not-exists
|
||||
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --create --topic unionflow.contributions.events --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1 --if-not-exists
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Vérification des Topics
|
||||
|
||||
### Lister tous les topics
|
||||
|
||||
```cmd
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
Résultat attendu :
|
||||
```
|
||||
unionflow.contributions.events
|
||||
unionflow.dashboard.stats
|
||||
unionflow.finance.approvals
|
||||
unionflow.members.events
|
||||
unionflow.notifications.user
|
||||
```
|
||||
|
||||
### Voir les détails d'un topic
|
||||
|
||||
```cmd
|
||||
docker exec kafka /opt/kafka/bin/kafka-topics.sh --describe --topic unionflow.finance.approvals --bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Topics Créés
|
||||
|
||||
| Topic | Partitions | Replication | Usage |
|
||||
|-------|------------|-------------|-------|
|
||||
| `unionflow.finance.approvals` | 3 | 1 | Workflow approbations financières |
|
||||
| `unionflow.dashboard.stats` | 3 | 1 | Mise à jour stats dashboard |
|
||||
| `unionflow.notifications.user` | 3 | 1 | Notifications utilisateurs |
|
||||
| `unionflow.members.events` | 3 | 1 | Events création/modification membres |
|
||||
| `unionflow.contributions.events` | 3 | 1 | Events paiements cotisations |
|
||||
|
||||
**Partitions** : 3 pour parallélisme (peut augmenter en prod si besoin)
|
||||
**Replication** : 1 (développement single-node)
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Tester la Configuration
|
||||
|
||||
### 1. Publier un message de test
|
||||
|
||||
```cmd
|
||||
docker exec -it kafka /opt/kafka/bin/kafka-console-producer.sh --topic unionflow.finance.approvals --bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
Tape un message JSON et appuie sur Entrée :
|
||||
```json
|
||||
{"eventType":"TEST","timestamp":"2026-03-14T19:00:00Z","data":{"message":"test"}}
|
||||
```
|
||||
|
||||
Ctrl+C pour quitter.
|
||||
|
||||
### 2. Consommer les messages
|
||||
|
||||
```cmd
|
||||
docker exec -it kafka /opt/kafka/bin/kafka-console-consumer.sh --topic unionflow.finance.approvals --bootstrap-server localhost:9092 --from-beginning
|
||||
```
|
||||
|
||||
Tu devrais voir le message de test. Ctrl+C pour quitter.
|
||||
|
||||
---
|
||||
|
||||
## ✅ Résultat Attendu
|
||||
|
||||
Après création des topics, redémarre le backend Quarkus :
|
||||
|
||||
```bash
|
||||
cd unionflow-server-impl-quarkus
|
||||
./mvnw quarkus:dev
|
||||
```
|
||||
|
||||
Les erreurs `UNKNOWN_TOPIC_OR_PARTITION` **disparaîtront** et tu verras :
|
||||
|
||||
```
|
||||
✅ Kafka consumers started successfully
|
||||
✅ Connected to topics: unionflow.finance.approvals, unionflow.dashboard.stats, ...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ❓ FAQ
|
||||
|
||||
### Puis-je supprimer mon Kafka actuel ?
|
||||
|
||||
**NON !** Ton Kafka actuel est parfait. Garde-le. Il manque juste les topics.
|
||||
|
||||
### Dois-je utiliser docker-compose ?
|
||||
|
||||
Non, ton setup actuel (conteneur `kafka` standalone) fonctionne très bien pour le développement.
|
||||
|
||||
### En production ?
|
||||
|
||||
En production (Kubernetes), les topics seront créés automatiquement par le backend au démarrage (via `auto.create.topics.enable=true` dans Kafka) ou via Helm charts.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Après Création des Topics
|
||||
|
||||
1. **Redémarrer backend Quarkus** : `./mvnw quarkus:dev`
|
||||
2. **Lancer mobile** : `flutter run --dart-define=ENV=dev`
|
||||
3. **Tester WebSocket** : Publier un event via Swagger UI → vérifier réception mobile
|
||||
|
||||
---
|
||||
|
||||
**Status** : ✅ Topics créés → Backend connecté → WebSocket fonctionnel
|
||||
Reference in New Issue
Block a user