Search code examples
messagingazureservicebus

Document message vs message enrichment


I am working on an enterprise system in which I want to replicate data from one bounded context (source) into another bc (destination). I definitely want to store the data in the destination bc, rather than fetch it when required as the volume of data is high.

I have reviewed many messaging patterns, but am struggling to decide between document message and message enrichment.

  1. Document message - when event occurs in source send the whole message to the destination via broadcast over service bus. Pros: simple, destination is decoupled from source. Cons: message size.

  2. Message enrichment - send message containing entity id and link back to the source data via broadcast over service bus. Pros: lite message. Cons: destination more coupled to source (although mitigated via link in payload), synchronous call required back to source to get the data.

Are there any other considerations I should be aware of here? I have read that large messages over service bus is a bad thing. But how big is bad?? And why is it that bad? There is a limit of 256kb per message on Azure Service Bus, but my messages would be maximum 1kb.

Any help would be greatly appreciated... Thanks.


Solution

  • 1 KB is definitely nothing big for Service Bus, so I think you are free to go with option 1.

    As you say, the payload limit is 256 KB, but even if you want to send bigger messages - a common pattern is to put the payload into blob storage and then send a link via Service Bus. But for messages that fit - don't bother.

    Note that the limit of 256 KB applies per batch, when you send many messages as a single operation. Still plenty of room for batching at 1 KB size.