

Every vehicle in the snapshot has different status - some of them are on service journey (status = on duty), some of them are parked at depots (status = parked), etc. This is step that could be shared across all connected clients and we can execute InvalidCoordinatesFilter on the server.Īnother filtering type - VehicleStatusFilter. These vehicles otherwise would be located on "Null Island". For example - we should do simple filtering - for example remove all vehicles with invalid coordinates( Lat = 0, Lng = 0).

When data is received from EventGrid we are going to broadcast it to the connected clients (either mobile app, browser or any other system).īefore data is sent to clients - some processing has to be done. Now we have something more in our architecture:īut before we get started with data broadcast, we have to cover data processing step here before broadcast - data profiles. Thanks to await - we are not blocking here. We can run while loop and await asynchronously till the moment then Channel reader gives us signal that it's now time to start reading message from the channel - because somebody wrote one or more messages there. Here we are using cool feature - async while loop. we are ready now to broadcast the data Var latestData = await FetchLatestSnapshot().ConfigureAwait(false) While (await _buffer.WaitToReadAsync(stoppingToken).ConfigureAwait(false))

Protected override async Task ExecuteAsync(CancellationToken stoppingToken) public SnapshotDispatcherBackgroundService(SnapshotReceiverBuffer buffer) Essentially what we need to get - is a message pump that is invoked every time there is a new item in the channel and preferably not to block the thread. Having abstractions around Channel data structure we can provide with some nice methods for the reader part. Second, in order for us to the this service up & running, we need to register it in the service collection (usually this is done in Startup.cs file): public void ConfigureServices(IServiceCollection services) If we inspect received EventGrid data - we see that there is only a reference to blob that has been generated and saved in Azure Storage and not the actual content. Now we need to distribute if further to connected clients (whoever it might be).Ĭode fragment that we now need to implement is between these lines: if (eventGridEvent.Data is StorageBlobCreatedEventData) We are now in the phase when data needs to be prepared and broadcasted to connected clients (either mobile apps, browsers, specific data feeds or any other consumer application).įollowing architecture is set for broadcast phase of our real-time public transport tracking system: We ended last part of this blog post series with a open question what to do next once we have received EventGrid event. Part 7.1 - Fixing Docker Image Metrics in Azure.Part 5 - Data Broadcast using gRPC and SignalR.Part 1 - Scene Background & Solution Architecture.This article is a part of Applied Cloud Stories initiative - aka.ms/applied-cloud-stories. This is next post in series about real-time public transport tracking system development based on Azure infrastructure and services.
