PubSub DeadLetters issues

Lagom Version: 1.3

Attempting to do: Notify all actors in the cluster that an event has been received from a message queue, this prompts them all to update in memory caches.

Issue encountered: When publishing my akka message, my code on the subscription never seems to fire. though i receive the following:

Message [java.lang.String] from Actor[akka://my-impl-application/deadLetters] to Actor[akka://my-impl-application/system/distributedPubSubMediator#855479769] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings ‘akka.log-dead-letters’ and ‘akka.log-dead-letters-during-shutdown’.

My Investigation: I have tried to find examples and found I was getting similar issues even using example code such as

I’ve noted almost all examples seems to suggest subscription be done async to publish logic (in the example the subscription is only done when a stream is opened), which doesn’t suit my needs. An example of the overall logic of my code is below (this isn’t the code, it’s a nice simplification):

public class MyService {
    //KafkaService is just an instance of com.lightbend.lagom.javadsl.api.Service with a single Topic
    public MyService(KafkaService service, PubSubRegistry pubSubRegistry) {
        PubSubRef<String> pubSubRef = pubSubRegistry.refFor(TopicId.of(String.class, "my_topic"));
            .atLeastOnce(Flow.<String>create().fromFunction(msg -> {
                return Done.getInstance();
        pubSubRef.subscriber().subscribe().map(msg -> {
            return msg;

application.conf = "my-impl-application"
akka {
  actor {
    provider = "cluster"
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = ""
      port = 2552
akka.cluster.seed-nodes = [

Expected: When an actor in my cluster receives a kafka event, an akka msg is published which ALL other actors consume and then do something.

Current Workaround: Currently as per I’m just building my own akka pubsub structure, though I would much prefer to use the built in Lagom feature

Where are you running your subscription graph ? Seems like you just build it.

How do you mean? As in it looks like in my code I’m just building the service but never user it.
I should probably have clarified I am injecting the service into a controller for the purposes of being created.

When you do

pubSubRegistry.refFor(TopicId.of(String.class, “my_topic”));

this ill return a PubSubRef[T] rigth ? After that you subscribe to the topic


this ill return a Source[T,Mat] rigth ? Then you need to run the source graph. If you can ignore you sink do that:


This ill execute your graph until that you ill not be abble to read any messages because you are just building the graph

How would that be in Java for lagom 1.3? As far as I can tell Akka 2.4 requires runWith with 2 parameters not 1.

With akka 2.4.20 you can use that =)

The second parameter is an Generic type for the materializer, you can use the runWIth function as i show before