-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Reef3rm4n/feature/postgres-message-broker/…
…durable_messages_and_topics Feature/postgres message broker/durable messages and topics
- Loading branch information
Showing
92 changed files
with
2,625 additions
and
2,517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
es4j-infrastructure/es4j-postgres-message-broker/diagrams/claiming.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@startuml | ||
participant "Database" as D #LightBlue | ||
participant "Es4j Postgres Message Broker" as EPMB | ||
|
||
EPMB -> D : Claim partition | ||
note over EPMB, D: The library claims a partition in the database | ||
|
||
loop every 30 seconds | ||
EPMB -> D : Heartbeat | ||
note over EPMB, D: A heartbeat is sent every 30 seconds to maintain the partition session alive | ||
end loop | ||
@enduml |
16 changes: 16 additions & 0 deletions
16
es4j-infrastructure/es4j-postgres-message-broker/diagrams/hash-ring.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@startuml | ||
participant "Es4j Postgres Message Broker" as EPMB | ||
participant "Database" as D #LightBlue | ||
|
||
EPMB -> EPMB : Startup | ||
note over EPMB: The broker starts up | ||
|
||
EPMB -> D : Read available partitions | ||
note over D, EPMB: The broker reads all available partitions from the database | ||
|
||
D --> EPMB : Return partitions | ||
note over EPMB: The database returns the list of available partitions | ||
|
||
EPMB -> EPMB : Add partitions to hash ring | ||
note over EPMB: The broker adds the partitions to its internal hash ring | ||
@enduml |
30 changes: 30 additions & 0 deletions
30
es4j-infrastructure/es4j-postgres-message-broker/diagrams/heartbeat-fail.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@startuml | ||
participant "Database" as D #LightBlue | ||
participant "Es4j Postgres Message Broker 1" as EPMB1 | ||
participant "Es4j Postgres Message Broker 2" as EPMB2 | ||
participant "Business Logic" as C4 | ||
"EPMB1" -> "EPMB1": trigger message consumers timer task | ||
C4 -> "EPMB1": sendMessage(partition-1) | ||
EPMB1 -> D : Claim partition | ||
note over EPMB1, D: The broker claims a partition in the database | ||
note over EPMB1: TimerTask is trigger for checking the availability of messages | ||
note over EPMB1: TimerTask is trigger heartbeat | ||
|
||
|
||
loop every 30 seconds | ||
alt Heartbeat Successful | ||
EPMB1 -> D : Heartbeat | ||
note over EPMB1, D: A heartbeat is sent every 30 seconds to maintain the connection | ||
else Heartbeat Fails | ||
EPMB1 -> D : Heartbeat | ||
note over EPMB1, D: Heartbeat failed | ||
|
||
EPMB2 -> D : Claim partition on channel signal | ||
note over EPMB2, D: The second broker claims the partition | ||
C4 -> EPMB2 : sendMessage(partition-1) | ||
"EPMB1" -> "Database": insertMessage | ||
"Database" -> EPMB2: message in partition | ||
EPMB2 -> "Database": startSession(partition-1) | ||
end | ||
end loop | ||
@enduml |
26 changes: 26 additions & 0 deletions
26
es4j-infrastructure/es4j-postgres-message-broker/diagrams/pg-broker.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@startuml | ||
participant "Business Logic" as C4 | ||
participant "Es4j Postgres Broker 1" as C1 | ||
participant "Es4j Postgres Broker 2" as C2 | ||
participant "Es4j Postgres Broker 3" as C3 | ||
participant "Database" as D #LightBlue | ||
|
||
C4 -> C1 : send(Message) | ||
|
||
C1 -> C1 : calculate_partition(Message) | ||
|
||
C1 -> D : Message (partition-1) | ||
|
||
D -> C1 : message(partition-1) | ||
note over C1: startSession(partition-1) | ||
note over C1: pollOnce = true | ||
|
||
D -> C2 : message(partition-1) | ||
note over C2: startSession(partition-1) | ||
note over C2: partition-1 already claimed | ||
|
||
D -> C3 : message(partition-1) | ||
note over C3: startSession(partition-1) | ||
note over C3: partition-1 already claimed | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...-postgres-message-broker/src/main/java/io/es4j/infrastructure/pgbroker/PgBrokerRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.es4j.infrastructure.pgbroker; | ||
|
||
import io.es4j.http.HttpRoute; | ||
import io.smallrye.mutiny.Uni; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.mutiny.core.Vertx; | ||
import io.vertx.mutiny.ext.web.Router; | ||
|
||
public class PgBrokerRoute implements HttpRoute { | ||
|
||
@Override | ||
public Uni<Void> start(Vertx vertx, JsonObject configuration) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void registerRoutes(Router router) { | ||
// todo implement end-points | ||
router.get("/postgres-message-broker/messages"); | ||
router.get("/postgres-message-broker/dlq"); | ||
router.get("/postgres-message-broker/tx"); | ||
router.post("/postgres-message-broker/message"); | ||
router.post("/postgres-message-broker/cancel"); | ||
router.post("/postgres-message-broker/retry"); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.