开发者

Erlang Supervisors - Shared Process Mailboxes

I have a supervisor process that monitors two child processes; a primary process and a backup process (in case the primary process exits).

If the primary process 开发者_StackOverflowgoes down whilst there are still messages in its mailbox, is there a way for the backup process to take over and process the messages that were left in the original primary process mailbox?


If you mean processes instead of nodes, and you want to make sure all incoming messages are processed. Either by the primary process or by the backup process, it's best to store incoming messages directly in a Mnesia table. That way you can continue processing in the backup proces.

That said, I think the problem you are trying to solve can be handled automatically by OTP. You never need to create backup processes. You can just tell the supervisor to re-spawn the same gen_server if one crashed.


What I generally do in such a situation is push incoming messages into an ets table. There are some subtleties to this. Discussed further here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜