3

I have an application wherein data is fetched from the SQL DB and sent to the service bus as brokered message. These are the steps:

  1. Data fetched from the DB(in batches of 1000)
  2. Each row of data converted into Brokered Message and added into a list.
  3. The list of 1000 brokered messages is sent to the service bus using SendBatchAsync method.

It is at the 3rd step that I am facing the issue. This is the code for that:

public async Task SendMessagesAsync(List<BrokeredMessage> brokeredMessageList)
        {
            try
            {
                var topicClient = CreateTopicClient();
                await topicClient.SendBatchAsync(brokeredMessageList);
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }

when the compiler comes to SendBatchAsync method, it gives an error that Error during communication with Service Bus. Check the connection information, then retry. with the inner exception being:

Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown. TrackingId:some guid here

However if I try sending 100 messages, it works fine. What can I do to make it send 1000 messages at a time?

Note: each message size is 1445 bytes

4

2 回答 2

6

不幸的是,您不能,因为您的总有效负载大小约为 1.4 MB(1445 字节 * 1000),而允许的批处理的最大大小为 256 KB。

参考:https ://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.topicclient.sendbatch.aspx (备注部分)

批处理的最大大小与单个消息的最大大小相同(当前为 256 Kb)。

我想你需要将批次进一步分成更小的批次,这样你就不会超过 256K 的限制。

于 2015-06-25T08:41:40.433 回答
2

可以在 Azure 服务总线中使用高级命名空间。这允许最大 1MB 的消息。虽然标题仍然限制为 64K。

PS - 在使用高级命名空间之前检查定价。

欲了解更多信息->

https://blogs.msdn.microsoft.com/servicebus/2016/07/07/things-to-know-about-premium-messaging/

于 2017-05-18T12:22:21.603 回答