Skip to content

Commit

Permalink
11_5_akka
Browse files Browse the repository at this point in the history
  • Loading branch information
JavaWebinar committed Dec 25, 2017
1 parent d523782 commit 5871203
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public static Config getConfig(String resource, String domain) {
return getConfig(resource).getConfig(domain);
}

public static Config getAppConfig(String path) {
return ConfigFactory.parseFile(getConfigFile(path)).resolve();
}

public static File getConfigFile(String path) {
return new File(AppConfig.APP_CONFIG.getString("configDir"), path);
}
Expand Down
15 changes: 15 additions & 0 deletions config_templates/akka.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
webapp {
include required(classpath("akka-common"))

akka {
remote.netty.tcp.port = 2554
}
}

mail-service {
include required(classpath("akka-common"))

akka {
remote.netty.tcp.port = 2553
}
}
46 changes: 46 additions & 0 deletions services/akka-remote/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>ru.javaops</groupId>
<artifactId>parent-web</artifactId>
<relativePath>../../parent-web/pom.xml</relativePath>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>akka-remote</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Akka Remote</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.12</artifactId>
<version>2.5.8</version>
<exclusions>
<exclusion>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
</exclusion>
<exclusion>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ru.javaops.masterjava.akka;

import akka.actor.ActorSystem;
import lombok.extern.slf4j.Slf4j;
import ru.javaops.masterjava.config.Configs;

@Slf4j
public class AkkaActivator {
private static final String AKKA_CONF = "akka.conf";

private ActorSystem system;

private AkkaActivator(String actorSystemName, String nodeName) {
log.info("Start AKKA System {} : {}", actorSystemName, nodeName);
system = ActorSystem.create(actorSystemName, Configs.getAppConfig(AKKA_CONF).getConfig(nodeName));
}

public static AkkaActivator start(String actorSystemName, String configName) {
return new AkkaActivator(actorSystemName, configName);
}

public void shutdown() {
if (system != null) {
log.info("Akka system shutdown");
system.terminate();
}
}
}
12 changes: 12 additions & 0 deletions services/akka-remote/src/main/resources/akka-common.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}

remote {
netty.tcp {
hostname = "127.0.0.1"
maximum-frame-size = 10000000b
}
}
}
1 change: 1 addition & 0 deletions services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<name>Services</name>
<modules>
<module>akka-remote</module>
<module>common-ws</module>
<module>mail-api</module>
<module>mail-service</module>
Expand Down

0 comments on commit 5871203

Please sign in to comment.