Handling Task Response from ConsumerSupervisor

Is there anyway to monitor the result of a Task spawned from a ConsumerSupervisor in a GenStage pipeline?

I’ve been playing around with it but it looks like once the task has finished executing it work, whether it succeeds or fails, it just terminates. I’d like to update the status of a job in my database based on the result of the Task started from ConsumerSupervisor. Is this possible?

Couldn’t you just make updating the status at the end part of the task itself?

The problem is I need the Task’s reply to know whether it failed and therefore how to update the job status.

You can wrap it in the func passed to Task

Task.start_link(fn ->
case process(event) do
{:ok, res} -> something
{:error, res} -> error_handler
end
end)

1 Like