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
This application simulates a simple indexing application to show the Flusswerk framework in action.
3
-
4
2
## Overview
5
3
6
-
The data processing logic is split in three components:
7
-
8
-
The [`Reader`](src/main/java/com/github/dbmdz/flusswerk/example/flow/Reader.java) receives a message from RabbitMQ and loads the corresponding document (as instance of `Document`).
The [`Transformer`](src/main/java/com/github/dbmdz/flusswerk/example/flow/Transformer.java) then takes the document and builds the required data for the Indexing API (an `IndexDocument`):
This application demonstrates the Flusswerk framework in action. A Flusswerk application typically takes an incoming message from a RabbitMQ queue, does something, and then may send any number of messages to other topics for further processing.
39
5
40
-
@Override
41
-
publicIndexDocumentapply(Documentdocument) {
42
-
IndexDocument indexDocument =newIndexDocument();
43
-
// ...
44
-
return indexDocument;
45
-
}
46
-
}
47
-
```
48
-
49
-
50
-
The [`Writer`](src/main/java/com/github/dbmdz/flusswerk/example/flow/Writer.java) finally takes the processed data, writes it to the Indexing API and sends messages to notify the next processing application.
6
+
The data processing logic is in [DemoProcessor](src/main/java/dev/mdz/flusswerk/example/flow/DemoProcessor.java). Usually all kinds of things can go wrong when processing data: Data might be corrupt, backends fail,... Flusswerk provides a simple way to handle these error cases with special exceptions.
| No error, everything just works |`EVERYTHING_FINE` (default) | This is the usual case, everything works as expected, data is processed. |
13
+
| Temporary error |`TEMPORARY`| Sometimes there are issues that will resolve themselves, and we can try processing the message again later. A typical example would be a temporary network issue or an API service that is restarting. |
14
+
| Permanent error |`PERMANENT`| In some cases it is clear that trying again later won't make a difference, e.g. if the data is corrupt. Then we stop processing for good. |
72
15
73
16
## Try yourself:
74
17
@@ -77,26 +20,27 @@ To try yourself, get the repository and RabbitMQ-Server:
Then start the `flusswerk-example` Application from your IDE and open the RabbitMQ-Management UI at http://localhost:15672 (Login in as `guest`/`guest`).
84
27
85
-
Drop the following message into the queue `search.index`:
28
+
Drop the following message into the queue `incoming`:
86
29
87
30
```json
88
-
{ "itemId": "42", "tracingId": "12345" }
31
+
{ "id": "42" }
89
32
```
90
33
91
-
In the queue `search.publish`, you will find the outgoing message send by the `Writer`:
34
+
You now should find a message in the queue `next`.
35
+
36
+
Now try the error cases:
92
37
93
38
```json
94
-
{
95
-
"envelope":{},
96
-
"tracingId":"12345",
97
-
"itemId":"42",
98
-
"source":"search"
99
-
}
39
+
{ "id": "42", "issue": "TEMPORARY" }
100
40
```
101
41
102
-
The field `envelope` contains Flusswerk specific metadata and is usually only used by the Framework itself.
0 commit comments