Azure ServiceBus:Client.Receive()对于消息>返回null. 64 KB [英] Azure ServiceBus: Client.Receive() returns null for messages > 64 KB

查看:74
本文介绍了Azure ServiceBus:Client.Receive()对于消息>返回null. 64 KB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用包含Stream和序列化对象的BrokeredMessage.根据文档,流是不是正文的一部分,标头限制为64 KB.大约67 KB的总消息远低于 256 KB的限制表示ServiceBus队列的消息大小.

I'm using a BrokeredMessage containing a Stream with a serialized object. According to the documentation the stream is part of the body not the header which is restricted to 64 KB. The overall message with about 67 KB is well below the limit of 256 KB for the message-size of ServiceBus queues.

  1. 我能够发送一条消息,它以正确的消息大小显示在队列中.

  1. I'm able to send a message and it shows up in the queue with the correct message-size.

发出Receive-命令后,将数据包从队列中删除,并相应地将计数器减1.但是,该操作遇到超时并返回null指针而不是BrokeredMessage.

After issuing the Receive-command the packet is removed from the queue and the counter is decremented accordingly. But, the operation runs into a timeout and returns a null-pointer instead of the BrokeredMessage.

我尝试了一个大小为42 KB的数据包,并且一切正常-发送,接收和反序列化.

I've tried with a packet with a size of 42 KB and all works well - sending, receiving and deserializing.

,为什么它不能与较大的消息一起使用,如何使它起作用?

Q Why doesn't it work with the larger message and how can I make it work?

修改0

我尝试接收填充有随机模式的byte数组:

I tried receiving a byte-array filled with a random pattern:

var bm = new BrokeredMessage(new byte[n])

  1. n = 63500起作用. (发送: HeaderSize = 53,BodySize = 63572; 接收: HeaderSize = 139,BodySize = 63572)
  2. n = 64000 不起作用. (发送: HeaderSize = 54,BodySize = 64072; 接收: null)
  1. n = 63500 does work. (send: HeaderSize = 53, BodySize = 63572; receive: HeaderSize = 139, BodySize = 63572)
  2. n = 64000 does not work. (send: HeaderSize = 54, BodySize = 64072; receive: null)

编辑1

@David Pfeffer就是这么简单:

@David Pfeffer It's just as simple as that:

var queueWork = QueueClient.CreateFromConnectionString(@"Endpoint=sb://***/;SharedAccessKeyName=***;SharedAccessKey=***", path, ReceiveMode.ReceiveAndDelete);
BrokeredMessage message = queueWork.Receive();

推荐答案

我无法重现此内容.这是我的示例代码:

I am unable to reproduce this. Here's my sample code:

var client = QueueClient.CreateFromConnectionString("Endpoint=sb://***.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=***", "queue", ReceiveMode.ReceiveAndDelete);
client.Send(new BrokeredMessage(new byte[100000]));
var msg = client.Receive();
// msg is happy

这篇关于Azure ServiceBus:Client.Receive()对于消息>返回null. 64 KB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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