File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,35 @@ public class MessageService {
6060}
6161```
6262
63+ ### Compound Operations
64+ ```
65+ public class MessageService {
66+ @KafkaListener(topic = "test-topic1", groupId = "test-group")
67+ public void handleMessage1(String message) {
68+ System.out.println("1-🕒 Received at " + System.currentTimeMillis());
69+ System.out.println("1-📥 Message: " + message);
70+ }
71+
72+ @KafkaListener(topic = "test-topic2", groupId = "test-group")
73+ @SendTo(topic = "processed-topic2")
74+ public String handleMessage2(String message) {
75+ System.out.println("2-🕒 Received at " + System.currentTimeMillis());
76+ System.out.println("2-📥 Message: " + message);
77+ // Forward processed message to another topic
78+ return "Processed: " + message;
79+ }
80+
81+ @KafkaListener(topic = "test-topic3", groupId = "test-group")
82+ @ShortCircuit(topic = "error-topic3")
83+ public void handleMessageWithError(String message) {
84+ if (message.contains("fail")) {
85+ throw new RuntimeException("Error detected in message!");
86+ }
87+ System.out.println("3-🕒 Message: " + message);
88+ }
89+ }
90+ ```
91+
6392## 🛠️ Architecture
6493
6594```
You can’t perform that action at this time.
0 commit comments