Skip to content

Commit 632e46c

Browse files
KotharuKotharu
authored andcommitted
Initial Commit
1 parent 8696022 commit 632e46c

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

akka-http/src/main/java/com/baeldung/akkahttp/AkkaHttpServer.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ public AkkaHttpServer(ActorSystem system, ActorRef userRegistryActor) {
2323
}
2424

2525
public static void main(String[] args) throws Exception {
26-
ActorSystem system = ActorSystem.create("helloAkkaHttpServer");
27-
final ActorMaterializer materializer = ActorMaterializer.create(system);
26+
ActorSystem system = ActorSystem.create("helloAkkaHttpServer");
27+
final ActorMaterializer materializer = ActorMaterializer.create(system);
2828

29-
ActorRef userActorRef = system.actorOf(UserActor.props(), "userActor");
29+
ActorRef userActorRef = system.actorOf(UserActor.props(), "userActor");
3030

31-
AkkaHttpServer app = new AkkaHttpServer(system, userActorRef);
31+
AkkaHttpServer app = new AkkaHttpServer(system, userActorRef);
3232

33-
final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = app.userRoutes.routes().flow(system, materializer);
33+
final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = app.userRoutes.routes()
34+
.flow(system, materializer);
3435

35-
final CompletionStage<ServerBinding> binding = Http.get(system).bindAndHandle(routeFlow,
36-
ConnectHttp.toHost("localhost", 8080), materializer);
36+
final CompletionStage<ServerBinding> binding = Http.get(system)
37+
.bindAndHandle(routeFlow, ConnectHttp.toHost("localhost", 8080), materializer);
3738

38-
System.out.println("Server is online at http://localhost:8080/");
39-
}
39+
System.out.println("Server is online at http://localhost:8080/");
40+
}
41+
}

akka-http/src/main/java/com/baeldung/akkahttp/UserRegistryMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.baeldung.akkahttp;
22

3+
import java.io.Serializable;
4+
35
/**
46
* Defines all messages related to User Actor
57
*

akka-http/src/main/java/com/baeldung/akkahttp/UserRoutes.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.baeldung.akkahttp;
22

3-
import java.time.Duration;
43
import java.util.Optional;
54
import java.util.concurrent.CompletionStage;
65
import java.util.concurrent.TimeUnit;
76

7+
import com.baeldung.akkahttp.UserRegistryMessages.ActionPerformed;
8+
import com.baeldung.akkahttp.UserRegistryMessages.CreateUser;
9+
810
import akka.actor.ActorRef;
911
import akka.actor.ActorSystem;
1012
import akka.event.Logging;
@@ -16,6 +18,7 @@
1618
import akka.http.javadsl.server.Route;
1719
import akka.pattern.PatternsCS;
1820
import akka.util.Timeout;
21+
import scala.concurrent.duration.Duration;
1922

2023
public class UserRoutes extends AllDirectives {
2124

0 commit comments

Comments
 (0)