I am using Channel from system.threading.channels in asp.net core 3.1 application where I am continuously writing into a channel and reading from it.
When I am reading a item from channel, I am making a database call to save the item.
Questions is, if database call fails, can I move to item back to channel to re-read it again?
private static async Task Consume(ChannelReader<int> c)
{
try
{
while (true)
{
int item = await c.ReadAsync();
// process item to the database
//if database call fails, can we move the item back to Channel
}
}
catch (ChannelClosedException) {}
}