超过了Azure服务总线SDK的SendBatch()方法上的链接异常上当前允许的限制(262144字节) [英] Exceeds the limit (262144 bytes) currently allowed on the link Exception on SendBatch() method of Azure service bus SDK

查看:61
本文介绍了超过了Azure服务总线SDK的SendBatch()方法上的链接异常上当前允许的限制(262144字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Azure服务总线SDK 3.1.7的SendBatch()方法将数据发送到Azure事件中心.以下是代码段:

We are using SendBatch() method of Azure service bus SDK 3.1.7 to send data to Azure Event Hub. Following is the code snippet :

foreach (var packet in transformedPackets)
        {
            EventData eventData = new EventData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(packet, settings)));;
            try
            {
                eventData.Properties.Add(AppConstants.TenantDeploymentUniqueIdKey, tenantDeploymentUniqueId);
                eventData.Properties.Add(AppConstants.DataTypeKey, DataTypeKey);
                byteCount += eventData.SerializedSizeInBytes;                   
                if (byteCount > MaxBatchSize)
                {
                    sender.SendBatch(transformedMessages);
                    transformedMessages.Clear();
                    byteCount = eventData.SerializedSizeInBytes;
                }
                transformedMessages.Add(eventData);
            }
            catch (System.Exception)
            {
                eventData.Dispose();
                throw;
            }

        }

在将事件数据添加到批处理之前检查SerializedSizeInBytes属性后发生的事件(允许的最大限制:256 KB),我们收到以下异常:

Event after checking the SerializedSizeInBytes property before adding the event data to the batch (Maximum allowed limit : 256 KB), we are getting the following exception :

接收到的消息(传递ID:0,大小:262279字节)超出了链接上当前允许的限制(262144字节). 在Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception异常) 在Microsoft.ServiceBus.Common.AsyncResult.End [TAsyncResult](IAsyncResult结果) 在Microsoft.ServiceBus.Common.AsyncResult 1.End(IAsyncResult asyncResult) at Microsoft.ServiceBus.Messaging.MessageSender.RetrySenderEventDataAsyncResult.End(IAsyncResult r) at Microsoft.ServiceBus.Messaging.MessageSender.EndSendEventData(IAsyncResult result) at Microsoft.ServiceBus.Messaging.EventHubSender.SendBatch(IEnumerable 1 eventDataList)

The received message (delivery-id:0, size:262279 bytes) exceeds the limit (262144 bytes) currently allowed on the link. at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.ServiceBus.Common.AsyncResult1.End(IAsyncResult asyncResult) at Microsoft.ServiceBus.Messaging.MessageSender.RetrySenderEventDataAsyncResult.End(IAsyncResult r) at Microsoft.ServiceBus.Messaging.MessageSender.EndSendEventData(IAsyncResult result) at Microsoft.ServiceBus.Messaging.EventHubSender.SendBatch(IEnumerable1 eventDataList)

推荐答案

将事件转换为单个AmqpMessage时,会将一些其他信息添加到批处理标头中.

When events are translated into a single AmqpMessage some additional information is added to the batch header.

确保所有EventData的总大小小于250k.

Make sure the aggregate size of all EventData falls below 250k.

在这里您可以找到有关此问题的详细信息:如何在发送到Microsoft Azure EventHub时使用客户端事件批处理功能

Here you can find detailed information for this issue: How to use client-side event batching functionality while Sending to Microsoft Azure EventHubs

这篇关于超过了Azure服务总线SDK的SendBatch()方法上的链接异常上当前允许的限制(262144字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆