Best practice for sending large messages on ServiceBus

[亡魂溺海] 提交于 2021-02-18 12:22:10

问题


We need to send large messages on ServiceBus Topics. Current size is around 10MB. Our initial take is to save a temporary file in BlobStorage and then send a message with reference to the blob. The file is compressed to save upload time. It works fine.

Today I read this article: http://geekswithblogs.net/asmith/archive/2012/04/10/149275.aspx The suggestion there is to split the message in smaller chunks and on the receiving side aggregate them again.

I can admit that is a "cleaner approach", avoiding the roundtrip to BlobStore. On the other hand I prefer to keep things simple. The splitting mechanism introduces increased complexity. I mean there must have been a reason why they didn't include that in the ServiceBus from the beginning ...

Has anyone tried the splitting approach in real life situation?

Are there better patterns?


回答1:


I wrote that blog article a while ago, the intention was to implement the splitter and aggregator patterns using the Service Bus. I found this question by chance when searching for a better alternative.

I agree that the simplest approach may be to use Blob storage to store the message body, and send a reference to that in the message. This is the scenario we are considering for a customer project right now.

I remember a couple of years ago, there was some sample code published that would abstract Service Bus and Storage Queues from the client application, and handle the use of Blob storage for large message bodies when required. (I think it was the CAT team at Microsoft, but I'm not sure).

I can't find the sample with a Quick google search, but as it's probably a couple of years old, it will be out of date, as the Service Bus client library has been improved a lot since then.

I have used the splitting of messages when the message size was too large, but as this was for batched telemetry data there was no need to aggregate the messages, and I could just process a number of smaller batches on the receiving end instead of one large message.

Another disadvantage of the splitter-aggregator approach is that it requires sessions, and therefore a session enabled Queue or Subscription. This means that all messages will require sessions, even smaller ones, and also the Session Id cannot be used for another purpose in the implementation.

If I were you I would not trust the code on the blog post, it was written a long time ago, and I have learned a lot since then :-).

The Blob Storage approach is probably the way to go.

Regards,

Alan



来源:https://stackoverflow.com/questions/27325171/best-practice-for-sending-large-messages-on-servicebus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!