简体   繁体   English

WCF文件流队列

[英]WCF filestream queue

I am trying to create a web-service, that would be able to receive a file from client, process it (for example open the txt file, change the values somehow etc.) and then provide it to client after it is processed. 我正在尝试创建一个Web服务,该服务将能够从客户端接收文件,对其进行处理(例如,打开txt文件,以某种方式更改值等),然后在处理之后将其提供给客户端。

The things I have done so far is that I have a service+host and WinForm application for client, that is able to choose file, send it and then get the list of files that are stored on served and manualy download selected file back (Im using WCF streaming). 到目前为止,我所做的事情是我有一个用于客户端的service + host和WinForm应用程序,它能够选择文件,发送文件,然后获取存储在服务中的文件列表,并手动下载所选文件(Im使用WCF流)。

Next thing I need to do is create some sort of queue - it would be nice to have the file download process from server automated. 接下来我要做的是创建某种队列-将服务器的文件下载过程自动化将是一件很不错的事情。 But there is also possibility, that before the server manage to process the file from client, the client could go (intetionaly or not) offline and thus the server would not be able to send the file back. 但是也有可能,在服务器设法从客户端处理文件之前,客户端可能会(无论是否在线)脱机,因此服务器将无法将文件发送回去。

I checked some manuals and tutorial and found out, that there is a built-in technology called MSMQ, that could be used in WCF - it simply put the data in queue, if the client/server is not avaiable atm and attempt to send them later. 我检查了一些手册和教程,发现有一种称为MSMQ的内置技术,可以在WCF中使用-如果客户端/服务器不可用atm,它只是将数据放入队列中并尝试发送它们后来。 The only problem is, that in each manual, they are working only with methods (they put methods call in queue) but not with files. 唯一的问题是,在每本手册中,它们仅使用方法(它们将put方法调用在队列中),而不使用文件。

My question is - is it possible to implement MSMQ with file streaming somehow? 我的问题是-是否可以通过某种方式用文件流实现MSMQ? Or should I choose different approach? 还是应该选择其他方法?

Thank you in advance 先感谢您

Your web service shouild save the uploaded image to a directory on your server and then return a JobID to the webpage. 您的网络服务应将上传的图像保存到服务器上的目录中,然后将JobID返回到网页。 The web service method could also then post a message using System.Messaging with that JobID (and all relevant file info, etc) to an MSMQ queue. 然后,Web服务方法还可以使用System.Messaging将具有该JobID(以及所有相关文件信息等)的消息发布到MSMQ队列。 You can then write a WCF service that uses MSMQIntegration Binding to listen to this queue. 然后,您可以编写使用MSMQIntegration绑定的WCF服务来侦听此队列。 You would write a method in this service that would perform whatever operations you wish to perform on the file, and the method would automatically take the message off the queue, or if the service was offline, the messages would remain there until this service is back online. 您将在此服务中编写一个方法,该方法将执行您希望对文件执行的任何操作,并且该方法将自动使消息脱离队列,或者如果该服务处于脱机状态,则消息将保留在那里,直到该服务返回为止线上。

Does this address your needs? 这是否满足您的需求?

:) David :) 大卫

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM