Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 2537fca

Browse files
committed
Add a simple implementation of an event bus using reactor
1 parent ca8054b commit 2537fca

File tree

16 files changed

+139
-25
lines changed

16 files changed

+139
-25
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ repositories {
88
}
99

1010
dependencies {
11+
// Prod
12+
implementation('io.projectreactor:reactor-bus:2.0.8.RELEASE')
13+
14+
// Test
1115
testCompile('org.junit.jupiter:junit-jupiter-api:5.3.2')
1216
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.3.2')
1317
}
@@ -22,4 +26,4 @@ test {
2226
reports {
2327
html.enabled = true
2428
}
25-
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package tv.codely;
2+
3+
import tv.codely.context.notification.module.push.application.create.SendPushToSubscribersOnVideoCreated;
4+
import tv.codely.context.video.module.video.domain.VideoCreated;
5+
import tv.codely.shared.infrastructure.bus.ReactorEventBus;
6+
7+
import java.util.Arrays;
8+
9+
public class Starter {
10+
public static void main(String[] args) {
11+
var sendPushToSubscribersOnVideoCreated = new SendPushToSubscribersOnVideoCreated();
12+
13+
var eventBus = new ReactorEventBus(Arrays.asList(sendPushToSubscribersOnVideoCreated));
14+
15+
eventBus.notify(new VideoCreated("Llegamos a 1M de subscribers!", "CodelyTV es una gran plataforma, CREMITA!"));
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package tv.codely.context.notification.module.push.application.create;
2+
3+
import tv.codely.context.video.module.video.domain.VideoCreated;
4+
import tv.codely.shared.application.DomainEventSubscriber;
5+
6+
public class SendPushToSubscribersOnVideoCreated implements DomainEventSubscriber<VideoCreated> {
7+
@Override
8+
public String subscribedTo() {
9+
return VideoCreated.NAME;
10+
}
11+
12+
@Override
13+
public void react(VideoCreated event) {
14+
System.out.println(
15+
String.format(
16+
"Hey! There is a new video with title <%s> and description <%s>",
17+
event.name(),
18+
event.description()
19+
)
20+
);
21+
}
22+
}

src/main/java/tv/codely/context/notification/module/push/application/find/.gitkeep

Whitespace-only changes.

src/main/java/tv/codely/context/notification/module/push/domain/.gitkeep

Whitespace-only changes.

src/main/java/tv/codely/context/notification/module/push/infrastructure/.gitkeep

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package tv.codely.context.video.module.video.application.create;
2+
3+
public class VideoCreator {
4+
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package tv.codely.context.video.module.video.domain;
2+
3+
import tv.codely.shared.domain.DomainEvent;
4+
5+
public class VideoCreated implements DomainEvent {
6+
public static final String NAME = "video.created";
7+
8+
private final String name;
9+
private final String description;
10+
11+
public VideoCreated(String name, String description) {
12+
this.name = name;
13+
this.description = description;
14+
}
15+
16+
public String domainEventName() {
17+
return NAME;
18+
}
19+
20+
public String name() {
21+
return name;
22+
}
23+
24+
public String description() {
25+
return description;
26+
}
27+
}

src/main/java/tv/codely/context/video/module/video/infrastructure/.gitkeep

Whitespace-only changes.

src/main/java/tv/codely/java_bootstrap/Greeter.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)