Skip to content

Conversation

@MWClayson-NHS
Copy link
Contributor

@MWClayson-NHS MWClayson-NHS commented Jul 14, 2025

Description

Adding a new function which will provide 3 main methods

  • Inbound Metric Tracker
  • Reconcile Participants
  • Inbound Metric DataService

This change adds the functionality to ensure that all participants received from the file and API are accounted for in either the exception table or Cohort Distribution.

Note the implementation of the Reconcile participant class is liable to change as the application evolves and is in a state which is tightly coupled to the current implementation.

image

Context

DTOSS-9195

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copy link
Contributor

@will-larkin-nhs will-larkin-nhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML docs on all functions pls

Comment on lines +17 to +18
COPY ./ReconciliationService /dotnet-function-app
WORKDIR /dotnet-function-app/ReconciliationService.Function/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
COPY ./ReconciliationService /dotnet-function-app
WORKDIR /dotnet-function-app/ReconciliationService.Function/
COPY ./ReconciliationService/ReconciliationService.Functiom /src/dotnet-function-app
WORKDIR /src/dotnet-function-app

this matches the pattern for the rest of the dockerfiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work as the code in core doesn't get copied.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fine can you still add /src before /dotnet-function-app so it matches the rest of the project

if (!result)
{
_logger.LogWarning("Metric failed to add to the database, Message will be deferred");
await messageActions.DeferMessageAsync(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we deferring messages here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we cannot add it to the database deferring enables us to check and retry the message. ensuring its eventually written.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defering messages can be a little tricky as you need to check for messages that have been deferred and it can lead to strange bugs where messages get missed. they also don't get retried automatically we need to go get them and then get their sequence number to retry them. if they are needing to be retried why not set set retry options on the service bus?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I understand this will autoretry and i should just allow the exception to be thrown?

Copy link
Contributor

@SamRobinson75684 SamRobinson75684 Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes. I would consider setting the max retry count that can be done in code but also in the azure portal
when creating the ServiceBusClient you can set something like this:

var clientOptions = new ServiceBusClientOptions
{
    RetryOptions = new ServiceBusRetryOptions
    {
        Mode = ServiceBusRetryMode.Exponential, 
        Delay = TimeSpan.FromSeconds(2),        
        MaxDelay = TimeSpan.FromSeconds(30),   
        MaxRetries = 5                       
    }
};

await using var client = new ServiceBusClient(connectionString, clientOptions);

this explains the use of ServiceBusRetryMode: https://azuresdkdocs.z19.web.core.windows.net/dotnet/Azure.Messaging.ServiceBus/7.19.0/api/Azure.Messaging.ServiceBus/Azure.Messaging.ServiceBus.ServiceBusRetryMode.html

more info on ServiceBusClientOptions: https://learn.microsoft.com/en-us/javascript/api/@azure/service-bus/servicebusclientoptions?view=azure-node-latest

blob_service_client.create_container("file-exceptions")
blob_service_client.create_container("nems-updates")
blob_service_client.create_container("nems-config")
blob_service_client.create_container("config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we name this something more descriptive/ specific?

environment:
- ASPNETCORE_URLS=http://*:7162
- AzureWebJobsStorage=${AZURITE_CONNECTION_STRING}
- ReconciliationTimer=5/5 * * * *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to enclose this value in quotes since there are spaces

Comment on lines +17 to +18
COPY ./ReconciliationService /dotnet-function-app
WORKDIR /dotnet-function-app/ReconciliationService.Function/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fine can you still add /src before /dotnet-function-app so it matches the rest of the project

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants