@patriknw: you mentioned the below: could you explain what I was trying to do vs. how it is intended to be used?
“However, I think you misunderstand how it is intended to be used. You try to use it with two levels of Sharding, one for the TodoList and one for the TodoService. The docs say " A single ShardingProducerController per ActorSystem (node) can be shared for sending to all entities of a certain entity type.” Reliable delivery • Akka Documentation"
I think that is the reason for the ClassCastException.
However, I don’t think you should access the TodoService via ClusterSharding.
The documentation says:
The producer and ShardingProducerController actors are supposed to be local so that these messages are fast and not lost. This is enforced by a runtime check.
At the example that would be:
// Start a single instance of the TodoService actor
ActorRef<TodoService.Command> todoService = context.spawn(TodoService.create(producerController), "producer");
That ActorRef can then be used for sending messages to the TodoService. For example, from a HTTP route or similar