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.
How do messages flow from producer to consumer? - Part 4
In Part 3, we used the postal service to build a mental model: a message is a letter, a channel is the route, a queue is a mailbox for one owner and a topic distributes an event to subscribers. The next question is practical: how does a provider file become a message, how does it reach the right destination and how do workers receive it? In this article, we are going to see channel adapters, publishers, claim checks, routers, dispatchers, polling consumers, event-driven consumers, competing consumers and ordering.
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 (this article)
- How to make messaging reliable and consistent? - Part 5
- What is event-driven architecture? - Part 6
- What is event sourcing? - Part 7
TL;DR Summary
- A message channel adapter translates a provider file or API response into a message understood by our platform.
- The publisher belongs after the boundary where the message meaning becomes valid; it should not publish an unvalidated provider row as a business event.
- A claim check stores a large payload in Blob Storage and sends only an authorised reference through the channel.
- A message router selects the destination, while a message dispatcher selects the handler inside the receiving process.
- Polling consumers ask for work; event-driven consumers receive callbacks from the messaging client.
- Competing consumers improve throughput but create an ordering trade-off; Service Bus sessions can group messages per ISIN.
Getting the message into the platform
The provider does not always speak our internal message language. A fund manager may send a CSV file through secure file transfer, an administrator may expose a SOAP service and a third-party vendor may provide a REST API. The first responsibility is to isolate these protocols from the rest of the integration flow.
What is a message channel adapter?
A message channel adapter is a bridge between an external protocol and an internal message channel. It reads the provider representation, validates the transport-level details and creates a command or document message for the next owner.
In our case, the adapter can perform the following steps,
- Discover a provider file or call the provider API.
- Check that the file is complete, readable and from the expected source.
- Preserve the provider file key, checksum and correlation information.
- Map provider-specific field names to a command such as
ValidateProviderFile. - Send the command to the validation queue.
- Record the adapter outcome without exposing protected data in logs.
The adapter should not become the whole business workflow. It knows how to speak SFTP, SOAP or REST; the validation service owns the decision about whether the content is valid. This separation lets us replace one provider without changing every consumer.
Where does the publisher belong?
A publisher creates and sends an event. A sender creates and sends a command. The provider adapter is normally a sender because it asks the validation owner to perform work. After validation and mapping have stored a canonical data point, the data point store can publish PriceDataPointChanged or StaticDataPointChanged.
Publishing too early creates a misleading event. If the adapter publishes PriceDataPointChanged before the NAV has passed validation, a performance consumer may calculate from a value which the platform later rejects. Publish a business event after the business fact is durable, or use an outbox record when the database and broker cannot share one transaction.
The publisher should set a stable MessageId, preserve CorrelationId, set ContentType and add small routing properties such as DataPoint=Price. It should not need to know every subscriber. Each subscription owns its own delivery and processing outcome, as we saw in Part 3.
The following diagram depicts the channel adapter as the border between two worlds. On the left, the provider system speaks its own language: it drops CSV files on SFTP with its own field names, and it knows nothing about our queues. On the right, our platform speaks messages and our own contracts. The channel adapter sits on the border: it polls the SFTP folder, parses the CSV, maps the provider’s fields to our names and sends a ValidateProviderFile command to the validation queue. The validation service never sees SFTP or CSV, so when a provider changes its file format, only the adapter changes.

The external provider is violet, the trapezoid is the adapter and the horizontal pipe is the channel. One adapter per provider protocol keeps provider-specific details from spreading into downstream consumers.
Claim check for large provider payloads
What is a claim check?
A claim check is a small reference to a large payload stored outside the message channel. In our postal analogy, the letter contains a locker number instead of carrying a large box through every mailbox.
A provider price file can contain many fund share classes and may be too large or too sensitive to copy into every queue and subscription. The adapter stores the file in a private Azure Blob Storage container and sends a claim-check message with the blob key, checksum, provider, file type and CorrelationId.
The following diagram depicts the claim check as two small steps around the channel, like the luggage counter at an airport. The provider adapter produces a message with data: a header, a small body and a large payload (the big “Data” square). (1) The check in step stores the payload in private Blob Storage and gets a key back, like a luggage tag. (2) It replaces the payload with that key, so only the small message with the claim check travels through the validation queue. (3) On the other side, the check out step uses the key to fetch the payload and puts it back, so the validation service receives the message with its data again, as if the payload had travelled all the way. The queue stays small and fast, and neither the adapter nor the validation service has to know about the store if the check-in and check-out steps live at the edges of the channel.

The flow is as follows,
- The adapter uploads the complete provider file to a private blob.
- It records the blob key and checksum.
- It sends a small
ValidateProviderFilemessage containing the claim check. - The validation consumer retrieves the blob using an authorised identity.
- It checks the checksum, reads the file and records validation results.
- Retention removes the blob only after the agreed replay period.
Must Do: Protect the claim check as if it were the file itself. Use an authorised reference, not an anonymous public URL, and define what happens when the message exists after the blob has expired.
Claim check is not a way to avoid payload design. The consumer still needs enough metadata to decide whether the referenced file is the correct provider file and whether it can be safely replayed.
Choosing the destination
After the adapter creates a message, the platform needs to select the right channel. The decision should use stable message metadata and should remain visible to operations.
What is a message router?
A message router examines a message and sends it to the correct destination without changing its meaning. A content-based router can inspect the message type, data point or schema version. In our fund platform, DataPoint=Static goes to reference-data processing, while DataPoint=Price goes to the price path.
The following diagram depicts a content-based router handling one message. A price message (P, with DataPoint = Price in its header) arrives on the inbound queue. The router doesn’t process it; it only looks at the header, applies its rules (price to the price queue, static to the static-data queue) and forwards the message, unchanged, to the price queue. The static-data route (dashed) is not taken for this message; a static data message would take it instead. So each processor receives only the kind of data it owns, and the senders don’t need to know which processor that is. In practice, also give the router a default route, such as an exceptions queue, so an unknown or new data type is never silently dropped.

The flow highlighted in purple is the route this price message takes: from the router to the price queue and on to the price processor. A Service Bus subscription can use a SQL filter for a simple DataPoint=Price rule, or an application router can make a decision when the rule requires a maintained business lookup.
var priceFilter = new Microsoft.Azure.ServiceBus.Filters.SqlFilter(
"DataPoint = 'Price'");
Keep infrastructure filters small and documented. A filter containing hidden business rules becomes difficult to test, and a wrong filter can make a consumer appear healthy while it receives no messages.
Must Consider: Route on stable contract values such as message type or data point, not on a provider display name. Otherwise, a harmless label change can send data to the wrong path.
What is a message dispatcher?
A message dispatcher chooses the handler inside the receiving process. The router answers, “which channel or service should receive this message?” The dispatcher answers, “which handler in this service understands it?”
For example, a price-processing process can dispatch PriceDataPointChanged to PriceChangedHandler, StaticDataPointChanged to StaticChangedHandler and an unknown type to an explicit rejection path. The dispatcher should validate ContentType and schema version before calling business code.
async Task DispatchAsync(Message message, CancellationToken token)
{
switch (message.UserProperties["DataPoint"] as string)
{
case "Price":
await priceHandler.HandleAsync(message, token);
break;
case "Static":
await staticHandler.HandleAsync(message, token);
break;
default:
throw new InvalidOperationException("Unknown data point");
}
}
The dispatcher should not catch every exception and return success. If it does, the queue looks healthy while a data point is lost. An unknown contract should be visible and should follow the failure policy from Part 5.
The following diagram depicts a message dispatcher inside one service. Ingestion sends mixed data point messages (P for price, S for static data, C for a correction) to the mapping subscription. The data mapping service has only one consumer on that channel: the message dispatcher. For each message it receives, the dispatcher reads the message type and hands it to the handler which knows that type, all inside the same process. Compare this with the router earlier in this article: a router chooses between channels (and therefore between services), while a dispatcher chooses between handlers inside one service. And unlike competing consumers, the handlers here do different work for different message types.

The dispatcher is not a second broker. It is the local switch inside one consumer process, and its unknown-message path must remain observable.
Receiving messages
Polling consumer versus event-driven consumer
A consumer receives and handles a message. There are two common ways for it to receive work.
| Consumer style | How it works | Good fit | Trade-off |
|---|---|---|---|
| Polling consumer | Asks the channel for work at intervals | Batch files or low-volume jobs | Longer intervals increase latency; shorter intervals create empty reads |
| Event-driven consumer | Registers a handler which the client invokes | Continuous queues and topics | Concurrency, locks and shutdown behaviour need careful control |
A polling consumer can check an Azure Blob Storage folder or queue every few minutes. It should record the last check, limit each batch and avoid overlapping polls. It is understandable for end-of-day provider files, but it is not an efficient way to imitate real-time processing.
An event-driven consumer registers a callback. In the Microsoft.Azure.ServiceBus .NET Standard client, RegisterMessageHandler accepts MessageHandlerOptions, including MaxConcurrentCalls and AutoComplete:
var options = new MessageHandlerOptions(HandleExceptionAsync)
{
AutoComplete = false,
MaxConcurrentCalls = 4
};
subscriptionClient.RegisterMessageHandler(
async (message, token) =>
{
await DispatchAsync(message, token);
await subscriptionClient.CompleteAsync(
message.SystemProperties.LockToken);
},
options);
Complete the message only after the required side effect is durable. If SQL Server is temporarily unavailable, abandon it for another delivery. If the body is permanently malformed, the failure path should eventually dead-letter it rather than polling the same invalid message forever.
The following diagram depicts the one difference between the two: who starts the receive. In the top row, the reconciliation job runs a polling consumer. The arrow points from the consumer to the queue because the consumer asks, “any messages?”, on its own schedule (for example, every 5 minutes, up to 100 messages), so it controls when and how much work it takes. In the bottom row, the performance service runs an event-driven consumer. The arrow points from the queue to the consumer because the messaging client calls the handler as soon as a message arrives (RegisterMessageHandler in Microsoft.Azure.ServiceBus), so the latency is low but the arrival rate drives the work.

In both rows, the sender and the queue are exactly the same; only the receiver’s implementation differs. So the choice is the consumer’s: poll for batch work and controlled load, and use an event-driven consumer when the message should be handled as soon as it arrives.
What are competing consumers?
Competing consumers are multiple worker instances reading from the same queue. The queue gives each message to one available worker at a time, allowing independent price messages to be processed in parallel.
The following diagram depicts competing consumers. Price ingestion sends price messages 1, 2 and 3 to the price queue. Three instances of the same price processor run as separate processes, and each has a consumer listening to the same queue. The consumers compete for the messages: each message is taken by exactly one of them (instance 1 takes message 1, instance 2 takes message 2, instance 3 takes message 3), and whichever consumer finishes first takes the next one. When the price volume grows, we add another instance; nothing changes for price ingestion or the queue.

This is different from the topic in Part 3: a topic copies the same event to different services, while competing consumers share one queue’s work between identical instances of one service. The same message can still be delivered again after a failure or an expired lock, so competing consumers do not remove the need for idempotency.
Use competing consumers when the work is independent or the write is idempotent. Start with a small concurrency value and measure database pressure. Adding workers to a database which is already the bottleneck only creates more locked messages and retries.
Message ordering
Message ordering means handling messages in the sequence required by the business. A queue may preserve enqueue order in limited conditions, but concurrent workers, retries and multiple producers can make application-level order different from arrival order.
For a fund share class, a later NAV should not be overwritten by an older message which arrives late. Include an effective date or provider revision and define whether an old message is ignored, held or treated as a correction.
Azure Service Bus sessions can group messages by SessionId, such as one ISIN or share class. A session can provide ordered processing for that group while different funds still use different sessions. If every fund shares one session, the whole queue becomes sequential.
| Choice | Benefit | Trade-off |
|---|---|---|
| No ordering requirement | Highest parallelism | Consumer handles any arrival order |
| Effective-date check | Protects current state | Older messages need a clear outcome |
| Session per ISIN | Ordered processing per fund | A busy fund can become a bottleneck |
| One global session | Simple sequence | Removes useful concurrency |
Ordering does not replace idempotency. A lock can expire, a process can restart and a message can be redelivered. The consumer still needs a safe write rule.
The following diagram depicts the problem and the fix. In the top half, two NAV messages for the same ISIN (A1, then the newer A2) sit in a plain queue with competing consumers. Consumer 1 takes A1 but is slow; consumer 2 takes A2 and finishes first. A1 is written last, so the older NAV overwrites the newer one and the store ends up stale (the red path). In the bottom half, every message carries SessionId = ISIN. A session-enabled queue gives all messages of one session to one consumer at a time, so consumer 1 handles A1 and then A2 in order, while consumer 2 handles B1 and B2 for another ISIN in parallel.

The session is the ordered mailbox for one fund share class. It improves consistency for that stream, but a busy ISIN can still become a bottleneck.
Guidelines for message flow
Keep adapters narrow
An adapter should translate protocols and provider names, not own every downstream business rule. Otherwise, adding one provider creates a large release risk.
Put the publisher at a meaningful boundary
Publish a command when a receiver needs to perform work. Publish an event after the fact is durable. Do not publish a success event for an operation which has not completed.
Keep routing visible
Document each route, filter, owner and rejection path. A routing rule hidden in code or portal configuration is difficult to diagnose during a backlog.
Limit payloads
Use a claim check for large files, and include enough metadata for validation and replay. Do not copy a provider file into every message body.
Scale deliberately
Competing consumers can improve throughput, but concurrency must match the downstream store. Measure queue age, processing time and lock expiry before increasing workers.
Design ordering before concurrency
Decide whether order matters per ISIN, provider file or event type. Then choose sessions, effective-date checks or independent processing. Otherwise, a scale change can create an incorrect fund view.
Wrap up
In this article, we have looked at message channel adapters, producer and publisher placement, claim check, message routers, dispatchers, polling consumers, event-driven consumers, competing consumers and ordering with Service Bus sessions. I really appreciate that you took the time to read this article. In the next article, I will walk you through the failure model, guaranteed delivery, retry, poison messages, dead-letter queues, replay, idempotency, deduplication and Saga consistency.
Related Posts
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.
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.