receive do
:some_message ->
# ...
:other_message ->
# ...
end
def handle_info(:some_message, state) do
# ...
end
def handle_info(:other_message, state) do
# ...
end
def handle_info(unknown, state) do
Logger.warn("Unknown message")
{:noreply, state}
end
Node.monitor(consumer_node, true)
monitor_ref = Process.monitor(consumer_pid)
send(consumer_pid, {monitor_ref, message})
receive do
{:ack, ^monitor_ref} ->
Process.demonitor(monitor_ref, [:flush])
{:DOWN, ^monitor_ref, _, _, _} ->
give_to_another_consumer(message)
{:nodedown, ^consumer_node} ->
give_to_another_consumer(message)
end
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine
BEAM architecture handbook - Andrea Leopardi  | Elixir Club Ukraine

BEAM architecture handbook - Andrea Leopardi | Elixir Club Ukraine

  • 31.
    receive do :some_message -> #... :other_message -> # ... end
  • 32.
    def handle_info(:some_message, state)do # ... end def handle_info(:other_message, state) do # ... end def handle_info(unknown, state) do Logger.warn("Unknown message") {:noreply, state} end
  • 81.
    Node.monitor(consumer_node, true) monitor_ref =Process.monitor(consumer_pid) send(consumer_pid, {monitor_ref, message}) receive do {:ack, ^monitor_ref} -> Process.demonitor(monitor_ref, [:flush]) {:DOWN, ^monitor_ref, _, _, _} -> give_to_another_consumer(message) {:nodedown, ^consumer_node} -> give_to_another_consumer(message) end