'Azure Function RabbitMq trigger stops receiving messages
I have Azure Function with RabbitMq trigger and it stops receiving any messages after certain time. The function is deployed in Azure. When I stop and then start again the function, it starts pulling messages again, but after a while it stops. When I run it locally on my machine the problem never occurs. My code looks like this:
[FunctionName(nameof(Bets))]
public async Task Bets([RabbitMQTrigger(nameof(Bets), ConnectionStringSetting = "RabbitConnection")] BasicDeliverEventArgs args,
[RabbitMQ(ConnectionStringSetting = "RabbitConnection")] IModel client, ILogger log)
{
var myQueueItem = Encoding.UTF8.GetString(args.Body);
var logEntry = new Log()
{
date = DateTime.UtcNow,
status = SuccessStatus,
input = myQueueItem,
queue = nameof(Bets)
};
try
{
var input = JsonConvert.DeserializeObject<Bet[]>(myQueueItem);
await _context.BulkInsertOrUpdateAsync(input);
log.LogInformation($"Finished input save: {myQueueItem}");
}
catch (Exception e)
{
client.BasicNack(args.DeliveryTag, false, true);
logEntry.status = "Error";
logEntry.error = e.Message;
log.LogError(e, e.Message, myQueueItem);
}
await _context.logs.AddAsync(logEntry);
await _context.SaveChangesAsync();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
