You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.error("Failed to process message from node: {}", nodeId, e);
109
+
return;
110
+
}
111
+
```
112
+
113
+
### Types
114
+
- Use primitive types where possible for performance.
115
+
- Use `List`, `Map`, `Set` interfaces rather than concrete implementations in method signatures.
116
+
- Initialize collections with appropriate implementations (e.g., `ArrayList`, `HashMap`, `HashSet`).
81
117
82
118
## 3. Architecture & Patterns
83
119
@@ -87,16 +123,27 @@ All new Java files must include the Apache License 2.0 header:
87
123
-**Design Patterns**:
88
124
-**Builder**: Used for complex configuration/message objects (e.g., `MqttPublishMessage.builder()`).
89
125
-**Listener**: Heavily used for events (`MqttProtocolListener`, `IMqttMessageListener`).
126
+
-**Decorator**: Used in `mica-mqtt-broker` for session management (`ClusterMqttSessionManager` wraps `IMqttSessionManager`).
127
+
128
+
### Cluster Module (mica-mqtt-broker)
129
+
- Built on t-io cluster for node-to-node communication.
130
+
- Uses `MqttBroker.create()` as entry point for cluster brokers.
131
+
- Fluent API for configuration (`MqttClusterConfig.enabled(true).clusterPort(9001)`).
132
+
- Cluster messages inherit from `ClusterMessage` base class.
133
+
- Session state is synchronized across nodes via `ClusterMqttSessionManager`.
90
134
91
135
## 4. Testing
92
136
93
-
- Write unit tests for new logic using JUnit.
137
+
- Write unit tests for new logic using JUnit (Jupiter).
94
138
- Place tests in the `src/test/java` directory corresponding to the package structure.
95
139
- Mock external dependencies where possible to keep tests fast.
140
+
- Cluster integration tests may have Windows-specific cleanup issues with t-io; focus on test assertions passing.
96
141
97
142
## 5. Agent Behavior Rules
98
143
99
144
-**No Assumptions**: Always verify file existence and content before editing.
100
145
-**Minimal Changes**: Only modify what is necessary to fulfill the request.
101
146
-**Preserve Style**: If you see a file using a specific style (even if it contradicts general rules), follow the file's local style (except for clearly erroneous logic).
102
147
-**Safety**: Do not commit secrets or breaking changes without user confirmation.
148
+
-**Verification**: After making changes, always run `mvn compile` to verify the code compiles.
149
+
-**Testing**: Run relevant tests after modifications to ensure no regressions.
0 commit comments