Why can't the example of Akka Platform Guide run?

Hi, I am reading the Akka Platform Guide, but I get problem in the example.

I download the source code of the first chapter Create the gRPC Cart service and compile, run it with SBT.

sbt -Dconfig.resource=local1.conf run

The source code:
https://developer.lightbend.com/docs/akka-platform-guide/microservices-tutorial/_attachments/1-shopping-cart-grpc-scala.zip

I am sure that I modify nothing. But it shows dead-letters occurred when running on my laptop.

[info] welcome to sbt 1.4.6 (AdoptOpenJDK Java 11.0.9.1)
[info] loading global plugins from C:\Users\Casper\.sbt\1.0\plugins
[info] loading settings for project shopping-cart-service-build from plugins.sbt ...
[info] loading project definition from E:\Downloads\shopping-cart-service\project
[info] loading settings for project shopping-cart-service from build.sbt ...
[info] set current project to shopping-cart-service (in build file:/E:/Downloads/shopping-cart-service/)
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] running shopping.cart.Main
[2021-03-12 21:45:50,029] [INFO] [akka.event.slf4j.Slf4jLogger] [] [] [ShoppingCartService-akka.actor.default-dispatcher-3] - Slf4jLogger starte
[2021-03-12 21:45:51,170] [INFO] [akka.remote.artery.tcp.ArteryTcpTransport] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-
akka.actor.default-dispatcher-3] - Remoting started with transport [Artery tcp]; listening on address [akka://ShoppingCartService@127.0.0.1:2551]
 with UID [7020411709129983039]
[2021-03-12 21:45:51,245] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.default-di
spatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - Starting up, Akka version [2.6.13] ...
[2021-03-12 21:45:51,550] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.default-di
spatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - Registered cluster JMX MBean [akka:type=Cluster]
[2021-03-12 21:45:51,551] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.default-di
spatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - Started up successfully
[2021-03-12 21:45:51,660] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.default-di
spatcher-6] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - No seed nodes found in configuration, relying on Cluster Bootstrap for j
oining
[2021-03-12 21:45:51,686] [INFO] [akka.cluster.sbr.SplitBrainResolver] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.a
ctor.default-dispatcher-3] - SBR started. Config: strategy [KeepMajority], stable-after [20 seconds], down-all-when-unstable [15 seconds], selfUn
iqueAddress [akka://ShoppingCartService@127.0.0.1:2551#7020411709129983039], selfDc [default].
[2021-03-12 21:45:53,532] [INFO] [akka.management.internal.HealthChecksImpl] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-
akka.actor.default-dispatcher-11] - Loading readiness checks [(cluster-membership,akka.management.cluster.scaladsl.ClusterMembershipCheck), (shar
ding,akka.cluster.sharding.ClusterShardingHealthCheck)]
[2021-03-12 21:45:53,533] [INFO] [akka.management.internal.HealthChecksImpl] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-
akka.actor.default-dispatcher-11] - Loading liveness checks []
[2021-03-12 21:45:53,839] [INFO] [akka.management.scaladsl.AkkaManagement] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-ak
ka.actor.default-dispatcher-11] - Binding Akka Management (HTTP) endpoint to: 127.0.0.1:9101
[2021-03-12 21:45:54,102] [INFO] [akka.management.scaladsl.AkkaManagement] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-ak
ka.actor.default-dispatcher-11] - Including HTTP management routes for ClusterHttpManagementRouteProvider
[2021-03-12 21:45:54,352] [INFO] [akka.management.scaladsl.AkkaManagement] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-ak
ka.actor.default-dispatcher-11] - Including HTTP management routes for ClusterBootstrap
[2021-03-12 21:45:54,368] [INFO] [akka.management.cluster.bootstrap.ClusterBootstrap] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCar
tService-akka.actor.default-dispatcher-11] - Using self contact point address: http://127.0.0.1:9101
[2021-03-12 21:45:54,449] [INFO] [akka.management.scaladsl.AkkaManagement] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-ak
ka.actor.default-dispatcher-11] - Including HTTP management routes for HealthCheckRoutes
[2021-03-12 21:45:55,193] [WARN] [akka.actor.ActorSystemImpl] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.defa
ult-dispatcher-3] - Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1.
[2021-03-12 21:45:55,467] [INFO] [akka.management.cluster.bootstrap.ClusterBootstrap] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCar
tService-akka.actor.default-dispatcher-11] - Initiating bootstrap procedure using config method...
[2021-03-12 21:45:55,467] [INFO] [akka.management.cluster.bootstrap.ClusterBootstrap] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCar
tService-akka.actor.default-dispatcher-3] - Bootstrap using `akka.discovery` method: config
[2021-03-12 21:45:55,499] [INFO] [akka.management.scaladsl.AkkaManagement] [akka://ShoppingCartService@127.0.0.1:2551] [akkaManagementBound] [Sho
ppingCartService-akka.actor.default-dispatcher-11] - Bound Akka Management (HTTP) endpoint to: 127.0.0.1:9101
[2021-03-12 21:45:55,561] [INFO] [akka.management.cluster.bootstrap.internal.BootstrapCoordinator] [akka://ShoppingCartService@127.0.0.1:2551] [a
kkaBootstrapInit] [ShoppingCartService-akka.actor.default-dispatcher-11] - Locating service members. Using discovery [akka.discovery.config.Confi
gServiceDiscovery], join decider [akka.management.cluster.bootstrap.LowestAddressJoinDecider], scheme [http]
[2021-03-12 21:45:55,577] [INFO] [akka.management.cluster.bootstrap.internal.BootstrapCoordinator] [akka://ShoppingCartService@127.0.0.1:2551] []
 [ShoppingCartService-akka.actor.default-dispatcher-11] - Looking up [Lookup(shopping-cart-service,Some(management),Some(tcp))]
[2021-03-12 21:45:55,608] [INFO] [akka.management.cluster.bootstrap.internal.BootstrapCoordinator] [akka://ShoppingCartService@127.0.0.1:2551] [a
kkaBootstrapResolved] [ShoppingCartService-akka.actor.default-dispatcher-11] - Located service members based on: [Lookup(shopping-cart-service,So
me(management),Some(tcp))]: [ResolvedTarget(127.0.0.1,Some(9101),None), ResolvedTarget(127.0.0.1,Some(9102),None), ResolvedTarget(127.0.0.1,Some(
9103),None)], filtered to [127.0.0.1:9101, 127.0.0.1:9102, 127.0.0.1:9103]
[2021-03-12 21:45:56,203] [INFO] [akka.actor.typed.ActorSystem] [] [] [ShoppingCartService-akka.actor.default-dispatcher-11] - Shopping online at
 gRPC server 127.0.0.1:8101
[2021-03-12 21:45:56,374] [INFO] [akka.management.cluster.bootstrap.contactpoint.HttpClusterBootstrapRoutes] [akka://ShoppingCartService@127.0.0.
1:2551] [] [ShoppingCartService-akka.actor.default-dispatcher-13] - Bootstrap request from 127.0.0.1:1318: Contact Point returning 0 seed-nodes [
]
[2021-03-12 21:45:56,588] [INFO] [akka.management.cluster.bootstrap.internal.BootstrapCoordinator] [akka://ShoppingCartService@127.0.0.1:2551] [a
kkaBootstrapSeedNodes] [ShoppingCartService-akka.actor.default-dispatcher-11] - Contact point [akka://ShoppingCartService@127.0.0.1:2551] returne
d [0] seed-nodes []
[2021-03-12 21:45:56,601] [INFO] [akka.management.cluster.bootstrap.internal.BootstrapCoordinator] [akka://ShoppingCartService@127.0.0.1:2551] [a
kkaBootstrapJoinSelf] [ShoppingCartService-akka.actor.default-dispatcher-13] - Initiating new cluster, self-joining [akka://ShoppingCartService@1
27.0.0.1:2551]. Other nodes are expected to locate this cluster via continued contact-point probing.
[2021-03-12 21:45:56,660] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [akkaMemberChanged] [ShoppingCartService-akka
.actor.default-dispatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - Node [akka://ShoppingCartService@127.0.0.1:2551] is JOI
NING itself (with roles [dc-default], version [0.0.0]) and forming new cluster
[2021-03-12 21:45:56,660] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.actor.default-di
spatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - is the new leader among reachable nodes (more leaders may exist)
[2021-03-12 21:45:56,677] [INFO] [akka.cluster.Cluster] [akka://ShoppingCartService@127.0.0.1:2551] [akkaMemberChanged] [ShoppingCartService-akka
.actor.default-dispatcher-3] - Cluster Node [akka://ShoppingCartService@127.0.0.1:2551] - Leader is moving node [akka://ShoppingCartService@127.0
.0.1:2551] to [Up]
[2021-03-12 21:45:56,704] [INFO] [akka.cluster.sbr.SplitBrainResolver] [akka://ShoppingCartService@127.0.0.1:2551] [] [ShoppingCartService-akka.a
ctor.default-dispatcher-3] - This node is now the leader responsible for taking SBR decisions among the reachable nodes (more leaders may exist)
[2021-03-12 21:45:58,350] [INFO] [akka.actor.LocalActorRef] [akka://ShoppingCartService@127.0.0.1:2551] [akkaDeadLetter] [ShoppingCartService-akk
a.actor.default-dispatcher-12] - Message [akka.actor.Status$Failure] from Actor[akka://ShoppingCartService/system/bootstrapCoordinator/contactPoi
ntProbe-127.0.0.1-9102#383864108] to Actor[akka://ShoppingCartService/system/bootstrapCoordinator/contactPointProbe-127.0.0.1-9102#383864108] was
 not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://ShoppingCartService/system/bootstrapCoordinat
or/contactPointProbe-127.0.0.1-9102#383864108] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration se
ttings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[2021-03-12 21:45:58,350] [INFO] [akka.actor.LocalActorRef] [akka://ShoppingCartService@127.0.0.1:2551] [akkaDeadLetter] [ShoppingCartService-akk
a.actor.default-dispatcher-12] - Message [akka.actor.Status$Failure] from Actor[akka://ShoppingCartService/system/bootstrapCoordinator/contactPoi
ntProbe-127.0.0.1-9103#646571814] to Actor[akka://ShoppingCartService/system/bootstrapCoordinator/contactPointProbe-127.0.0.1-9103#646571814] was
 not delivered. [2] dead letters encountered. If this is not an expected behavior then Actor[akka://ShoppingCartService/system/bootstrapCoordinat
or/contactPointProbe-127.0.0.1-9103#646571814] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration se
ttings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

As a beginner, I spent 2 days to try to solve it. But it’s too complex for me. Even I tried to migrate the project build tool from SBT to Gradle. But it didn’t work too.

In fact, I suppose that the configurations of Akka components is the most complex part of Akka programming.

Thanks.

Hi, sorry to hear that it doesn’t work for you. I downloaded same 1-shopping-cart-grpc-scala.zip and for me it starts correctly, with a log line:

[2021-03-12 15:38:59,237] [INFO] [akka.actor.typed.ActorSystem] [] [] [ShoppingCartService-akka.actor.default-dispatcher-21] - Shopping online at gRPC server 127.0.0.1:8101

The dead letters you see are not necessarily a problem. Your Akka Cluster is starting up correctly as seen by

Node [akka://ShoppingCartService@127.0.0.1:2551] is JOINING itself (with roles [dc-default], version [0.0.0]) and forming new cluster

You are missing the “Shopping online at gRPC server”, which makes me think that maybe you are accidentily running the https://developer.lightbend.com/docs/akka-platform-guide/microservices-tutorial/_attachments/0-shopping-cart-start-scala.zip, which isn’t starting the gRPC server.

Look in your Main class. You should have:

    val grpcInterface =
      system.settings.config.getString("shopping-cart-service.grpc.interface")
    val grpcPort =
      system.settings.config.getInt("shopping-cart-service.grpc.port")
    val grpcService = new ShoppingCartServiceImpl
    ShoppingCartServer.start(
      grpcInterface,
      grpcPort,
      system,
      grpcService

Sorry, I find the gRPC server is started on my laptop. The grpcurl commands get expected result now.

I’m confused in the problem of dead-letter. The last 2 days are wasted. The next problem is to finish the migration from sbt to gradle. :stuck_out_tongue:

It’s my build.gradle unfinished below. Except the dependencies, could you mind to give me any advice about it?

plugins {
    id 'java'
    id 'scala'
    id "com.lightbend.akka.grpc.gradle" version "1.1.1-8-c5f23b67"
    id 'application'
}

repositories {
    mavenCentral()
}

mainClassName = "shopping.cart.Main"

dependencies {
    // https://mvnrepository.com/artifact/org.scala-lang/scala-compiler
    implementation group: 'org.scala-lang', name: 'scala-compiler', version: '2.13.4'

    // https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor-typed
    implementation group: 'com.typesafe.akka', name: 'akka-actor-typed_2.13', version: '2.6.13'

    // https://mvnrepository.com/artifact/com.lightbend.akka.management/akka-management-cluster-bootstrap
    implementation group: 'com.lightbend.akka.management', name: 'akka-management-cluster-bootstrap_2.13', version: '1.0.10'


    // https://mvnrepository.com/artifact/org.scalatest/scalatest
    testImplementation group: 'org.scalatest', name: 'scalatest_2.13', version: '3.2.5'

    // https://mvnrepository.com/artifact/junit/junit
    testImplementation group: 'junit', name: 'junit', version: '4.13.1'

    // https://mvnrepository.com/artifact/org.slf4j/slf4j-api
    implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
}

test {
    useJUnitPlatform()
}

The Java examples are using Maven if that helps.

Thank you very much.

I’ll be more careful to study the examples.

Hi @Casperlet,

for examples using Gradle, you can have a look at the Akka gRPC template. You can use the template to build an empty project on your machine using:

sbt new akka/akka-grpc-quickstart-java.g8

from a terminal.
That particular template demonstrates using the Akka gRPC plugin from Gradle (alongside MAven and sbt) so it can be a good help for your migration.

Cheers,

@ignasi35 Thank you. It’s the 2nd time to meet you.

I clone the project and create a new project “hello world”. The build.gradle is like this below (What I missed are task runServer and runClient):

The last version of “com.lightbend.akka.grpc.gradle” is 1.1.1-8-c5f23b67. It supports Scala 2.13 now.

plugins {
  id 'scala'
  id 'application'
  id "com.github.maiflai.scalatest" version "0.26"
  id "com.lightbend.akka.grpc.gradle" version '1.1.1'
}

repositories {
  mavenCentral()
  mavenLocal()
}

dependencies {

  // The Gradle plugin for Akka-gRPC doesn't support 2.13:
  // https://github.com/akka/akka-grpc/pull/1025
  compile 'com.typesafe.akka:akka-actor-typed_2.12:2.6.13'
  compile 'com.typesafe.akka:akka-discovery_2.12:2.6.13'
  compile 'com.typesafe.akka:akka-protobuf_2.12:2.6.13'
  compile 'com.typesafe.akka:akka-stream_2.12:2.6.13'
  compile 'com.typesafe.akka:akka-pki_2.12:2.6.13'

  compile 'com.typesafe.akka:akka-http_2.12:10.2.4'
  compile 'com.typesafe.akka:akka-http2-support_2.12:10.2.4'

  compile 'ch.qos.logback:logback-classic:1.2.3'

  testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.12:2.6.13'
  testImplementation 'com.typesafe.akka:akka-stream-testkit_2.12:2.6.13'
  testImplementation 'org.scalatest:scalatest_2.12:3.1.1'
  // optional in Scalatest
  testRuntime 'com.vladsch.flexmark:flexmark-all:0.35.10'
  // Required by https://github.com/maiflai/gradle-scalatest
  testRuntime 'org.pegdown:pegdown:1.4.2'
}

task runServer(type: JavaExec) {
  classpath = sourceSets.main.runtimeClasspath

  main = 'com.example.helloworld.GreeterServer'
}


task runClient(type: JavaExec) {
  classpath = sourceSets.main.runtimeClasspath

  main = 'com.example.helloworld.GreeterClient'

  // arguments to pass to the application
  if (project.hasProperty("GreeterClient.user"))
    args  project.getProperty("GreeterClient.user")
}

application {
  mainClassName = 'com.example.helloworld.GreeterServer'
}

Best regards.