Akka DistributedPubSubMediator handle null values(supervisorStrategy)

I am using Akka as a pub sub system in my project, so far all is going great, but I have one problem,

when calling the following:
this.mediator.tell(new DistributedPubSubMediator.Publish(“akka-demo-topic”, null), getSelf());

The destination(a router) stops receiving messages after the publishing of null body(all future msg sent are deadletters), is it possible to override the mediator supervisorStrategy in order to log the error but not stop the end point from receiving future message’s

p.s. my workaround is to check if msg is null before publishing and I will use it as a last resort, but I would really like akka to deal with it

Usually tell itself throws if you try to send a null message but in this case the message is already sent/received by pubsub when that happens. I think it would make sense with a null check throwing NPE in the Publish message constructor (and maybe other similar wrapper message types in Akka as well)

I created an issue tracking improving this: Null messages and wrapper message types · Issue #31340 · akka/akka · GitHub

1 Like