发送大邮件到ServiceStack服务 [英] Send a large message to a ServiceStack service

查看:131
本文介绍了发送大邮件到ServiceStack服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个服务,将允许客户端发送一个包含大量数据的消息,我不知道如何组织的API。

I need to create a service that will allow a client to send a message containing a large amount of data and I'm not sure how to structure the API.

假设一个客户想要保存它包含可变数量相关对象的新对象。例如,一个命令,一个包含有对的OrderDetail对象中有数个行项目。一个订单可以具有与其相关的在1000的OrderDetail对象,其每一个可以包含数据的20-40KB。客户端需要知道服务已收到整个订单。

Let's say a client wants to save a new object which contains a variable number of related objects. For instance, an Order, which contains several line items contained in OrderDetail objects. An Order may have over a 1000 OrderDetail objects related to it, each of which may contain 20-40KB of data. The client needs to know that the service has received the entire order.

我想用ServiceStack创建此探索。创建一个高流量的服务是不是我很熟悉。我们通常会使用WCF,而且好像人们只是建议增加邮件大小限制,以适应大消息。我不知道这是与WCF的最佳策略,更不用说ServiceStack。

I would like to explore using ServiceStack to create this. Creating a high traffic service is not something I'm very familiar with. We would typically use WCF, and it seems like people just recommend increasing the message size limit to accommodate a large message. I'm not sure if that's the best strategy with WCF, let alone ServiceStack.

这将是更好的互送OrderDetail成为它自己的信息?我会关注保持整个订单去这条路线的完整性。或者我应该保持这个数据的一个大消息20-40MB?或者我应该尝试流它作为一个文件?

Would it be better to send each OrderDetail as it's own message? I would be concerned about keeping the integrity of the entire Order going this route. Or should I just keep this as a single large message 20-40MB of data? Or should I try to stream it as a file?

推荐答案

使用的 ServiceStack的protobuf的支持 - 协议缓冲区是那里最高效和紧凑的有线格式。由于它的简单,首先尝试一下,调查ServiceStack串流选项之前。

Use ServiceStack's ProtoBuf support - protocol buffers is the most efficient and compact wire format out there. Since it's simpler, try that first, before investigating the Streaming options in ServiceStack.

如果您发现您的服务将极大地受益流,比这里的一对的发送流ServiceStack 演示如何ServiceStack服务里面流。它展示了如何使用 IRequiresRequestStream 它可以让你流请求主体在您的服务:

If you've identified that your service will greatly benefit from Streaming, than here's an article on sending a stream to ServiceStack that shows how to Stream inside ServiceStack services. It shows how to use IRequiresRequestStream which lets you stream the Request Body in your services:

请求DTO:

[Route("/upload/{FileName}", "POST")]
public class UploadPackage : IRequiresRequestStream
{
    public System.IO.Stream RequestStream { get; set; }

    public string FileName { get; set; }
}

要请求体流访问被注入到 RequestStream 请求DTO的属性。

Access to the Request Body Stream is injected into the RequestStream property of the Request DTO.

这篇关于发送大邮件到ServiceStack服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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