What is event-driven architecture? - Part 6
Event-driven architecture with a mutual fund data pipeline in .NET: event contracts, publishing, subscription filters, consumers and the trade-offs.
What is event-driven architecture? - Part 6
A fund data platform is not finished when it stores a value. An event is a message which records a fact that has already happened, such as PriceDataPointChanged; unlike the command explained in Part 3, it is not asking one service to perform an action. The same NAV or fund reference change may need to update performance calculations, search, websites, factsheets, ratings and reconciliation. Calling all these consumers synchronously makes ingestion slow and makes one unavailable consumer block the provider flow. In the previous article, we discussed reliable messaging, retry, dead-letter queues, replay, idempotency and deduplication. In this article, we are going to see what event-driven architecture is, why we need it, its trade-offs and a worked fund-data pipeline using .NET and Azure messaging services.
Enterprise Integration Patterns series:
- What is enterprise integration and why do we need it? - Part 1
- What are the styles of integration? - Part 2
- What are messages, commands and events? - Part 3
- How do messages flow from producer to consumer? - Part 4
- How to make messaging reliable and consistent? - Part 5
- What is event-driven architecture? - Part 6 (this article)
- What is event sourcing? - Part 7
TL;DR Summary
- Event-driven architecture communicates important facts as events so independent consumers can react.
- A producer emits an event, a channel transports it and one or more consumers process their own subscription.
- Event notification says where to read state; event-carried state transfer includes the state needed by the consumer.
- Azure Service Bus topics and subscriptions provide durable application messaging; Azure Event Grid provides reactive event routing and was generally available in January 2018.
- The fund pipeline can publish
PriceDataPointChangedandStaticDataPointChangedafter validated data is stored. - Eventual consistency, duplicate delivery, ordering, schema evolution and debugging are trade-offs which must be designed and monitored.
Why do we need event-driven architecture?
In a synchronous flow, the provider adapter receives a file, writes the price and calls performance, search, factsheet and reconciliation services one after another. If search is unavailable, should the provider file fail? If the factsheet service takes a minute, should the ingestion process hold the provider connection open? These questions show that the consumers do not all belong to the same transaction.
Event-driven architecture lets the ingestion capability publish the fact that a data point changed. Each consumer decides how it reacts. The performance service can recalculate returns, the website sync can update its store, and reconciliation can raise an exception when the provider value disagrees with the mapped value. The platform becomes more proactive because a new consumer can subscribe to the event instead of adding another direct call to the ingestion service.
This does not mean every interaction should become an event. A caller which needs an immediate validation answer may still use an API. Events are useful when the producer should announce a completed fact and consumers can process it independently.
What is event-driven architecture?
Event-driven architecture (EDA) is an architecture in which producers publish events representing facts that have occurred, and consumers react to those events through an event channel.
In simple terms, one component says, “this happened”, and other components decide what they need to do. The producer does not normally call every consumer directly. The event channel, subscription rules and consumer ownership form the integration boundary.
The main building blocks are,
- Event producer - The component which knows that a business fact occurred.
- Event - An immutable statement such as
PriceDataPointChanged. - Event channel - A topic, subscription or event-routing service.
- Event consumer - A component which reacts to the event and owns its result.
- Projection or downstream store - A read model, index, calculation or report built from events.
An event is not a command. PriceDataPointChanged says that a price changed. RecalculateReturns would ask one owner to perform work. Keeping the difference clear helps us avoid broadcasting commands to consumers which do not own the action.
Event notification versus event-carried state transfer
An event notification carries a small statement and identifiers. For example, PriceDataPointChanged may contain ISIN, data point name, price date and an event id. The performance consumer then reads the current price from the data store.
Event-carried state transfer includes the values needed by the consumer, such as old NAV, new NAV, currency, effective date and source. The consumer can process without calling the producer back. This reduces synchronous coupling, but it increases message size and requires the event to carry a sufficiently stable representation.
| Choice | Benefit | Trade-off |
|---|---|---|
| Event notification | Small contract and one source of current state | Consumer depends on a follow-up read |
| Event-carried state transfer | Consumer can react independently | More schema and versioning responsibility |
In our case, a data-point event should contain enough values for the performance and reconciliation consumers to do useful work. It should not copy the complete fund profile or provider file into every subscription.
The fund-data event pipeline
The following diagram depicts the two halves of the event-driven fund-data pipeline. On the left, fund managers, administrators and third-party vendors send data through the ingestion adapter, validation and mapping, and the data point store. This side produces durable facts; it does not call every downstream consumer directly.

The flow highlighted in purple is the NAV price change from PriceDataPointChanged through the fund-data-events topic, the DataPoint = 'NAV' subscription and into Performance calculation. On the right, filtered subscriptions deliver StaticDataPointChanged and other data point events independently to Search / website sync, Factsheet regeneration, Reconciliation and Downstream sync. The note in the diagram is the important EDA rule: producers do not know the consumers; adding a consumer means adding a subscription.
Let us walk through the flow,
- Fund managers, administrators and third-party vendors provide fund static data and daily prices.
- An ingestion adapter handles the provider-specific file, REST API or SOAP response.
- Validation checks required fields, types, dates, currencies, ISIN format and source rules.
- Mapping translates provider names into canonical data points such as
Fee,Sector,BenchmarkorPrice. - The data point store writes the accepted value and preserves the provider source and effective date.
- The platform publishes a data point event after the accepted change is durable.
- Service Bus topic subscriptions or Event Grid handlers deliver the event to consumers.
- Consumers build their own outcome and record success or failure independently.
The event must not be published before the data point is durable unless the contract explicitly describes a tentative change. Otherwise, a consumer can receive an event which points to state that does not exist after a process restart. An outbox can close this gap when the database and broker cannot share one transaction.
Event contract in .NET
The following event contract is intentionally small. It carries the identity and old and new values required for a data-point change. In a real platform, the value types and serialisation policy should be agreed by the owner and versioned.
public sealed class DataPointChanged
{
public string EventId { get; set; }
public string CorrelationId { get; set; }
public string Isin { get; set; }
public string ShareClass { get; set; }
public string DataPoint { get; set; }
public string OldValue { get; set; }
public string NewValue { get; set; }
public DateTime EffectiveDate { get; set; }
public string Source { get; set; }
}
public sealed class PriceDataPointChanged : DataPointChanged
{
public decimal? Nav { get; set; }
public decimal? Bid { get; set; }
public decimal? Offer { get; set; }
}
StaticDataPointChanged can use the same base contract with a data point such as Fee, Sector, AssetClass or Benchmark. If the shape of the event becomes incompatible, publish a new event type or schema version instead of making old consumers guess which fields have changed.
Publishing with Microsoft.Azure.ServiceBus
The Microsoft.Azure.ServiceBus .NET Standard client was available for .NET Core applications in 2018. A publisher can serialise the event to a Message, set the technical headers and add a user property used by subscription filters.
using Microsoft.Azure.ServiceBus;
using Newtonsoft.Json;
using System.Text;
using System.Threading.Tasks;
public async Task PublishAsync(
TopicClient topicClient,
DataPointChanged changed)
{
var json = JsonConvert.SerializeObject(changed);
var message = new Message(Encoding.UTF8.GetBytes(json))
{
MessageId = changed.EventId,
CorrelationId = changed.CorrelationId,
SessionId = changed.Isin
};
message.UserProperties["DataPoint"] = changed.DataPoint;
message.UserProperties["EventType"] =
changed.GetType().Name;
await topicClient.SendAsync(message);
}
The publisher should be called after the local data point write is durable, or it should use an outbox record written in the same database transaction. The event id must be stable across a retry so that broker duplicate detection and consumer idempotency can help.
Subscribers and filters
Each consumer should have its own subscription when it has a different delivery policy or failure ownership. The performance subscription can receive only price events, while a static-profile subscription can receive sector, benchmark, currency and fee changes.
Service Bus subscription rules can use a SQL filter on UserProperties. The filter is configured as part of the subscription setup:
using Microsoft.Azure.ServiceBus.Filters;
var priceRule = new SqlFilter(
"DataPoint = 'Price'");
The filter is not enough by itself. The consumer should still validate the event type, schema version and data point. A filter change can be deployed incorrectly, and an event can be sent with a wrong property. Fail closed for unknown data rather than calculating a value from an untrusted shape.
The consumer can register an explicit message handler:
var options = new MessageHandlerOptions(
ExceptionReceivedHandler)
{
AutoComplete = false,
MaxConcurrentCalls = 4
};
subscriptionClient.RegisterMessageHandler(
async (message, token) =>
{
var changed = Deserialize<DataPointChanged>(
message.Body);
await returnsCalculator.RecalculateAsync(
changed.Isin,
changed.EffectiveDate,
token);
await subscriptionClient.CompleteAsync(
message.SystemProperties.LockToken);
},
options);
The consumer should use the event-carried values when the contract promises them, or read the current data point when the event is a notification. It must be idempotent because a message may be delivered again after a timeout. When the calculation succeeds, it can publish a ReturnsRecalculated event or update its own store; it should not alter the source data point owned by ingestion.
What do the consumers do?
Performance and risk calculations
When NAV changes, the performance consumer recalculates returns and volatility for the affected fund and periods. It can queue a calculation command internally when the work is expensive. A stale calculation should be visible through a last-calculated timestamp, otherwise consumers cannot distinguish “no change” from “calculation failed”.
Search and website synchronisation
The search consumer updates a downstream index with fund name, ISIN, currency, sector and other searchable fields. The website synchronisation process can update a cache or read model. These consumers may accept eventual consistency if the user interface shows the last update time.
Factsheet regeneration
The factsheet consumer can mark a document as needing regeneration when fees, benchmark or performance values change. It may batch several changes to avoid generating one document for every field in a provider file. The batch window is a business decision; it should not be hidden inside an arbitrary timer.
Reconciliation
The reconciliation consumer compares the mapped value and the provider end-of-day file. A difference creates an exception with the provider, ISIN, date and data point. Reconciliation should not silently overwrite the stored value, because the purpose is to make disagreements visible.
Downstream stores
Other stores or search indexes can subscribe according to their needs. Each consumer owns its checkpoint, retry and rebuild process. A topic gives them independent delivery state, but it does not give them a common transaction.
Challenges in event-driven architecture
Eventual consistency
The website may update before the factsheet, and the performance result may be ready after the price is visible. Explain this to consumers and display timestamps where it matters. Do not promise synchronous consistency when the architecture deliberately uses asynchronous delivery.
Ordering and duplicates
Events can arrive out of order or more than once. Use Service Bus sessions per ISIN when ordered processing is required, and use an effective date or version on the write. Idempotency is required even when sessions are used.
Debugging and ownership
A user issue may cross an adapter, topic, four subscriptions and several stores. CorrelationId, EventId, producer identity and effective date must be logged at each boundary. Every subscription needs an owner and a runbook.
Schema evolution
Consumers may not upgrade at the same time. Add optional fields in a compatible way, keep old fields during migration and publish a new version for a breaking meaning change. Contract tests should check the event shape and important semantics.
Monitoring
Monitor publication failure, subscription lag, oldest event age, dead-letter count, duplicate count and consumer completion time. An event topic with no publisher errors can still be failing the business if a consumer is stopped or a filter excludes all messages.
For an earlier discussion of combining Event Grid notifications and Service Bus commands, refer to Event-driven microservices with Event Grid and Service Bus. Azure Event Grid was generally available in January 2018 and is useful for reactive event routing from Azure resources, Event Hubs and custom topics. Service Bus remains a better fit for durable application commands, sessions and dead-letter handling.
Must Do and Must Consider
Must Do: Publish events only for facts which have a clear owner, stable meaning and consumer value.
Must Consider: Decide whether each event is a notification or carries state. This decision changes consumer coupling, payload size and replay behaviour.
Must Be Aware: A topic can make delivery independent, but it cannot make an unsafe consumer idempotent or an invalid contract meaningful.
Note: Start with one end-to-end event, including monitoring and replay, before publishing every internal field change as a separate event.
Wrap up
In this article, we have looked at event-driven architecture, event producers and consumers, event notification versus event-carried state transfer, a fund-data pipeline, .NET event contracts, Microsoft.Azure.ServiceBus publishing and subscription filters, and the challenges of eventual consistency and schema evolution. I really appreciate that you took the time to read this article. In the next article, I will walk you through event sourcing, append-only event streams, projections, checkpoints and rebuilding a fund reference-data view.
Related Posts
How do messages flow from producer to consumer? - Part 4
How messages flow from producer to consumer: channel adapters, claim check, routers, dispatchers, polling and competing consumers, and ordering.
What are messages, commands and events? - Part 3
Messages, envelopes, commands and events, producers and consumers, channels, queues, topics, brokers and buses, explained with a postal-service model.
What is enterprise integration and why do we need it? - Part 1
Why a mutual fund data platform needs enterprise integration, the common challenges and why a broker beats point-to-point connections.