Netty将httprequest添加到服务器处理(Netty add httprequest to server handling)
我在我的项目中使用微服务架构。 对于服务间通信,我使用消息队列NATS 。 我写了一个网关,处理所有的http请求并把它放到队列中。 所有端点服务都订阅了此队列。
在端点服务中,我使用基于Netty IO的Xitrum 。 当我从队列中获取请求时,我将其反序列化为FullHttpRequest。 但是我不知道如何将它发送到我的netty服务器,它可以根据业务逻辑处理它(例如,不使用外部httpclient,可以将其发送到localhost)
是否有可能使用netty api将FullHttpRequest实例发送到netty服务器(监听localhost:8000)? 或者可能是另一种解决方案 常见的方法是什么?
I use microservice architecture in my project. And for interservice communication I use message queue NATS. I wrote a gateway, that handle all http requests and put it to queue. All end point services are subscribed to this queue.
At endpoint services I use Xitrum based on Netty IO. When I get request from queue, I deserialise it to FullHttpRequest. But I don't know how to send it to my netty server, that can handle it according to business logic (without using external httpclient, for example, that can send it to localhost)
Is there any possibility to send FullHttpRequest instance to netty server (listening localhost:8000) using netty api? Or may be another solution. What is the common approach?
原文:https://stackoverflow.com/questions/39014049
满意答案
我会用一个单独的服务API来解决这个问题。 上传许多可能很大的文件的任务是一个长期运行的过程,您不希望触摸您的Web应用程序。 这种方法的主要优点是,如果出现问题,它不会影响您的Web应用程序。 如果上载失败,您不希望重新启动Web应用程序以解决此问题。
由于您担心这种方法的可扩展性,我会考虑使用后台任务管理器,这对于这类即发即弃的任务非常适合。 就个人而言,我使用并推荐了Hangfire ,因为它附带了一个漂亮的集成仪表板 ,可让您在运行时观察任务。 它还允许您自动重试失败(可配置),我认为它总体上很适合您的需求。
我将它用于类似的情况,其中我需要建立多个websocket连接,并且如果它失败则重新建立一个。 我有一个小程序,通过参数将服务添加到我的Hangfire队列。
其他选项包括Quartz.Net和FluentScheduler,但遗憾的是我对它们并不熟悉。
I would approach this with a separate service API. The task of uploading many potentially large files is a long-running process that you don't want touching your web app. The main advantage to this approach is that if something goes wrong, it does not affect your web application. If an upload fails, you don't want to restart your web application to account for that.
Since you are worried about scalability regarding this approach, I would consider using a background task manager, which is perfect for these sort of fire-and-forget tasks. Personally, I use and recommend Hangfire, as it comes with a beautiful integrated dashboard that lets you observe your tasks as they run. It also allows you to automatically retry on failure (configurable), and I think overall it suits your needs well.
I use it for a similar situation wherein I need to establish multiple websocket connections, and re-establish one if it were to fail. I have a small program that adds services to my Hangfire queue via arguments.
Other options include Quartz.Net and FluentScheduler, but unfortunately I am not nearly as familiar with them.
相关问答
更多为业务应用程序准备好ASP.NET MVC(集成第三方控件/组件)?(ASP.NET MVC ready for business applications (integrating 3rd party controls/components)?)
将ASP.Net网格数据输出到excel wo第三方dll(Export ASP.Net grid data to excel w.o. third party dll)
ASP.NET的第三方会话状态提供程序(Third party session state provider for ASP.NET)
在ASP.NET MVC中放置第三方插件/库的位置(Where to put third-party plugins/libraries in ASP.NET MVC)
Asp.net核心WEB API安全的第三方中间件路线?(Asp.net core WEB API secure 3rd party middleware routes?)
用于将上传传递给第三方的ASP.Net架构(ASP.Net architecture for passing upload to third party)
ASP.NET MVC和提供第三方API(ASP.NET MVC and Providing Third-Party API)
免费的第三方ASP.NET控件集合?(Free third party ASP.NET control collections?)
Durandal是否妨碍了我的POST到第三方asp.net处理程序?(Is Durandal getting in the way of my POST to a 3rd party asp.net handler? 405 Method not allowed error)
在ASP.net Web应用程序上启用第三方模块集成[关闭](Enable 3rd Party Module Integration on your ASP.net Web Application [closed])
相关文章
更多java socket server
Netty入门实例-编写服务器端程序
Solr Server对外提供Web Service的沟通方式 使用SolrJ跟Solr Server通信
Hadoop的thrift server配置
ubuntu server 安装ssh服务
Netty入门实例-时间服务器
solr搜索提示,将词添加到词库中
HTML5服务器事件发送(Server-Sent Events)【HTML5教程 - 第十三篇】
《Windows Server 2008服务器架设与管理教程(项目式)》扫描版[PDF]
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!