//process the message recieved private async Task ProcessMessagesAsync(Message message, CancellationToken token) { //convert to a Number by way of String -> JSON -> Number BusinessLogic.Number myPayload = JsonConvert.DeserializeObject <BusinessLogic.Number>(Encoding.UTF8.GetString(message.Body)); //Process that Number //will release when finished: prevents memory leaks using (var scope = Services.CreateScope()) { //get the repository var _repository = scope.ServiceProvider.GetRequiredService <IRepository>(); try { //place the number await _repository.PlaceNumberAsync(myPayload); } catch (Exception e) { string danger = "Cannot Process this Number: " + e; _logger.LogError(danger); } finally { //signal we are finished await _queueClient.CompleteAsync(message.SystemProperties.LockToken); } } }
//process the data to the repository public async Task Process(BusinessLogic.Number num) { }