简体   繁体   English

如何将内容从httpWebRequest从Web角色传输到Microsoft Azure中的辅助角色

[英]How to transfer content from httpWebRequest from Web Role to a Worker Role in Microsoft Azure

Help a newbie out please: 请帮助新手:

What I have in mind is this: 我想到的是:

  1. Web role receives an http request. Web角色收到一个http请求。 (done) (完成)
  2. the url supposed to help determine particular instance of the worker role. 该网址应有助于确定辅助角色的特定实例。 (done) (完成)
  3. the content of the request supposed to go to a worker role for [processing (it can be quite large and likely of type xml or json or blob or something else) 请求的内容应该转到工作角色中进行[处理(它可能很大,可能是xml或json或blob或其他类型)
  4. worker role receives the data 工作角色接收数据
  5. worker role parses/processes the data from the content and does some calcs. worker角色解析/处理来自内容的数据并进行一些计算。 (done) (完成)
  6. worker role sends a response back to the web role. 辅助角色将响应发送回Web角色。 (likely a string or something similar to the data in the request: can be quite large as well). (可能是字符串或类似于请求中数据的内容:也可能很大)。

Items #3 and #4 is where I have most of the problem with: not sure what do do here. 项目#3和#4是我最大的问题所在:不确定在这里做什么。
Item #6 i believe i have SOME idea on what to do, but would love to hear your suggestions 项目#6我相信我对做什么有一些想法,但很想听听您的建议

What I know is this: 我所知道的是:

  • I cant use queue: there is a size limitation I believe, which will prevent me from using it. 我不能使用队列:我相信有大小限制,这将阻止我使用它。
  • I dont think I will be able to use shared storage because how the web role is right now - long story 我认为我将无法使用共享存储,因为网络角色现在如何-长话短说
  • That leaves me with using endpoint: unless someone tells that this is absolutely impossible, then I will have to think of using the shared storage. 这使我不得不使用终结点:除非有人告诉我这绝对不可能,否则我将不得不考虑使用共享存储。

Appreciate all your inputs in advance. 预先感谢您的所有输入。

You can certainly find out an internal endpoint of a worker role instance from a web role instance using code. 您当然可以使用代码从Web角色实例中找出辅助角色实例的内部端点。 See this thread for more details: How to get web role input endpoint in worker role? 有关更多详细信息,请参见此线程: 如何在辅助角色中获取Web角色输入端点? .

However I see one problem with your approach. 但是,我发现您的方法存在一个问题。 You mentioned that web role will communicate with worker role using an internal endpoint to send the data and then wait for worker role to process that data and send the response back. 您提到过,Web角色将使用内部端点与辅助角色进行通信以发送数据,然后等待辅助角色处理该数据并将其发送回。 While technically its possible to do so, it would cause some scalability issues because you're now tying up your web role. 从技术上讲,虽然这样做是可能的,但会引起一些可伸缩性问题,因为您现在要绑定自己的Web角色。 Furthermore, you have to decide in your code which worker role instance should process the data (assuming there're more than one instances). 此外,您必须在代码中决定哪个工作角色实例应处理数据(假设有多个实例)。

My recommendation would be to get the request and persist the request data in blob storage. 我的建议是获取请求并将请求数据保留在Blob存储中。 You will get a URL of the blob. 您将获得该Blob的URL。 Then write a message in a queue with the URL of the blob. 然后将消息与Blob的URL写入队列。 Once the message is written to the queue, your web role can notify the user that the request has been submitted. 将消息写入队列后,您的Web角色可以通知用户请求已提交。 Worker role instances would poll this queue periodically and work on the message. 辅助角色实例将定期轮询此队列并处理消息。 They will get the blob URL from message contents, fetch the contents and work on it. 他们将从消息内容中获取Blob URL,获取内容并对其进行处理。 Once the work is processed, worker role could write to a queue/table indicating that the work is completed. 一旦处理完工作,辅助角色就可以写入队列/表,指示工作已完成。 Web role could constantly poll this table or queue and once the task is completed it can notify the user. Web角色可以不断轮询该表或队列,一旦任务完成,它可以通知用户。

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

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