akka/akka — pull request #893 by RayRoestenburg (2012-11-24 17:24:40+00:00)
Title: #2739 fix for producer bug in restart of producer

Added that the producer de-registers its endpoint when it is restarted at preRestart.

The problem was that the producerChild would not be (re)-initialized at restart because the registry thought the producer was already registered, so the producer never got a reference to the send processor again. de-registering at preRestart solves this problem because that way the preStart register will actually register, instead of thinking that it is already registered. Because of sending in order and order of preRestart and preStart we can be guaranteed that the endpoint will be de-registered and registered in order in the producer registry, which is an actor. Since the producer uses the producerChild to handle messages before the endpoint is registered there is no issue with losing messages during de-register and register.

Experimented with the consumer working the same way, but that meant that a user would have to wait for de-activation and activation in order before sending messages to consumer at consumer restart or otherwise lose out on messages, so I have not changed that because you would rather have the consumer be able to receive messages as much as possible. Maybe a feature for later to include a way to let the user indicate that the consumer should re-register endpoint at restart. For now the user can just stop a consumer and create a new one.