Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5871203

Browse files
committed
11_5_akka
1 parent d523782 commit 5871203

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed

common/src/main/java/ru/javaops/masterjava/config/Configs.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public static Config getConfig(String resource, String domain) {
1515
return getConfig(resource).getConfig(domain);
1616
}
1717

18+
public static Config getAppConfig(String path) {
19+
return ConfigFactory.parseFile(getConfigFile(path)).resolve();
20+
}
21+
1822
public static File getConfigFile(String path) {
1923
return new File(AppConfig.APP_CONFIG.getString("configDir"), path);
2024
}

config_templates/akka.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
webapp {
2+
include required(classpath("akka-common"))
3+
4+
akka {
5+
remote.netty.tcp.port = 2554
6+
}
7+
}
8+
9+
mail-service {
10+
include required(classpath("akka-common"))
11+
12+
akka {
13+
remote.netty.tcp.port = 2553
14+
}
15+
}

services/akka-remote/pom.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>ru.javaops</groupId>
9+
<artifactId>parent-web</artifactId>
10+
<relativePath>../../parent-web/pom.xml</relativePath>
11+
<version>1.0-SNAPSHOT</version>
12+
</parent>
13+
14+
<artifactId>akka-remote</artifactId>
15+
<version>1.0-SNAPSHOT</version>
16+
<name>Akka Remote</name>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>${project.groupId}</groupId>
21+
<artifactId>common</artifactId>
22+
<version>${project.version}</version>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>com.typesafe.akka</groupId>
27+
<artifactId>akka-remote_2.12</artifactId>
28+
<version>2.5.8</version>
29+
<exclusions>
30+
<exclusion>
31+
<groupId>com.typesafe</groupId>
32+
<artifactId>config</artifactId>
33+
</exclusion>
34+
<exclusion>
35+
<groupId>org.scala-lang</groupId>
36+
<artifactId>scala-library</artifactId>
37+
</exclusion>
38+
</exclusions>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.scala-lang</groupId>
42+
<artifactId>scala-library</artifactId>
43+
<version>2.12.4</version>
44+
</dependency>
45+
</dependencies>
46+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package ru.javaops.masterjava.akka;
2+
3+
import akka.actor.ActorSystem;
4+
import lombok.extern.slf4j.Slf4j;
5+
import ru.javaops.masterjava.config.Configs;
6+
7+
@Slf4j
8+
public class AkkaActivator {
9+
private static final String AKKA_CONF = "akka.conf";
10+
11+
private ActorSystem system;
12+
13+
private AkkaActivator(String actorSystemName, String nodeName) {
14+
log.info("Start AKKA System {} : {}", actorSystemName, nodeName);
15+
system = ActorSystem.create(actorSystemName, Configs.getAppConfig(AKKA_CONF).getConfig(nodeName));
16+
}
17+
18+
public static AkkaActivator start(String actorSystemName, String configName) {
19+
return new AkkaActivator(actorSystemName, configName);
20+
}
21+
22+
public void shutdown() {
23+
if (system != null) {
24+
log.info("Akka system shutdown");
25+
system.terminate();
26+
}
27+
}
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
akka {
2+
actor {
3+
provider = "akka.remote.RemoteActorRefProvider"
4+
}
5+
6+
remote {
7+
netty.tcp {
8+
hostname = "127.0.0.1"
9+
maximum-frame-size = 10000000b
10+
}
11+
}
12+
}

services/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<name>Services</name>
1111
<modules>
12+
<module>akka-remote</module>
1213
<module>common-ws</module>
1314
<module>mail-api</module>
1415
<module>mail-service</module>

0 commit comments

Comments
 (0)