Integrating Play with Lagom

java
akka-cluster
lagom

(Adarsh Singh) #1

Hi All, Am trying to integrate lagom persistence API with Play. lagom gitter channel is actively helping me with that. Now I am stuck with a play issue for which I need your help.

Problem statement: When am trying to run play + lagom in cluster mode.
I am getting this error: [error] a.r.EndpointWriter - dropping message [class akka.actor.ActorSelectionMessage] for non-local recipient [Actor[akka.tcp://inventory@127.0.0.1:2552/]] arriving at [akka.tcp://inventory@127.0.0.1:2552] inbound addresses are [akka.tcp://play-dev-mode@127.0.0.1:2552]

Here are my config files:
file: app.common.conf
play.akka.actor-system = “inventory”

akka {

actor.provider = “akka.cluster.ClusterActorRefProvider”

remote {
enabled-transports = [“akka.remote.netty.tcp”]
netty.tcp {
hostname = “127.0.0.1”
port = 2552
}
log-remote-lifecycle-events = off
}

cluster {
seed-nodes = [
“akka.tcp://inventory@127.0.0.1:2552”,
“akka.tcp://inventory@127.0.0.1:2551”]
}
}

file: app.development.conf
include “application.common.conf”

akka {

actor.provider = “akka.cluster.ClusterActorRefProvider”

remote {
enabled-transports = [“akka.remote.netty.tcp”]
netty.tcp {
hostname = “127.0.0.1”
port = 2551
}
log-remote-lifecycle-events = off
}

cluster {
seed-nodes = [
“akka.tcp://inventory@127.0.0.1:2552”,
“akka.tcp://inventory@127.0.0.1:2551”]
}
}

@TimMoore from lagom team helped me with following answer:
@adarshsingh_90_twitter looks like that actor system name isn’t being used: akka.tcp://play-dev-mode@127.0.0.1:2552
hmm OK so Play does have two actor systems
in development mode
Looks like the wrong one has remoting enabled
@adarshsingh_90_twitter I can’t find clear documentation about it, but here’s the source https://github.com/playframework/playframework/blob/2.6.x/framework/src/play-server/src/main/scala/play/core/server/DevServerStart.scala#L208-L224
@adarshsingh_90_twitter one of them is used for the Akka HTTP server, the other for the application itself
We want to disable remoting for the one running the server
People in the Play channel might have a better idea than I do

Can you guys point me to the right forum or help me with debug further!


(Rich Dougherty) #2

Play has two actor systems when run in “dev mode” (using sbt’s run command). The main actor system picks up settings from configuration under the akka namespace. The dev mode server actor system (which you probably don’t want in the cluster) picks up settings from play.akka.dev-mode first and then akka as a fallback. What you could try doing is putting all your cluster settings under akka - like you’re doing now - but then also add settings to disable the cluster under play.akka.dev-mode. This should result in the clustering running for one actor system but not both.

See this thread for more info: Configuring Akka HTTP backend


(Rich Dougherty) #3

PS: There’s a play-1 tag on this discussion topic. What version of Play are you using?


(Adarsh Singh) #4

Thanks @richdougherty for the details. Other solution which I found was to add the below line in build.sbt, which worked but not sure whether it is the right way of doing. Will consider your solution as well

PlayKeys.devSettings := Seq(
“play.akka.dev-mode.akka.actor.provider” -> “akka.actor.LocalActorRefProvider”
)

play version= 2.6
sbt.version=0.13.16
scalaVersion=2.12.4

Will this impact integration tests, do I have to change any configs?