首页 \ 问答 \ Netty将httprequest添加到服务器处理(Netty add httprequest to server handling)

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
更新时间:2022-12-07 07:12

最满意答案

我会用一个单独的服务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控件模型(这将约为ASP.NET控件供应商编写的控件的99.9%),则他们必须重写其控件。 那里有多少工作是非常不同的,这取决于他们的控制架构 - 他们已经使用的ajax越多,他们就越容易将其更改为MVC。 用于exsample的ASP.NET AJAX控件工具包可以使用MVC。 您可以在WWW.ASP.NET的视频中了解如何执行此操作: http : //www.asp.net/learn/mvc-videos/video-373.aspx If they use the ASP ...
  • 我建议你,如果你使用GridView的模板字段中的任何控件像Bullted List,RadioButtonList,CheckBoxList,你想在Excel中导出,因为它只使用以下代码... public void ExportToExcel(GridView gv, string filename) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("co ...
  • 查看此博客文章 (在帖子的末尾有一个第三方提供商列表,如NCache , ScaleOut和Memcached )。 Checkout this blog post (at the end of the post there's a list of third party providers like NCache, ScaleOut and Memcached).
  • 我开始用类似于此的文件夹结构替换Content和Script文件夹: 上市 CSS 脚本 图片 ... 的fancybox markitup 我把它全部放在名为“Public”的文件夹中的原因是,与Views或Controller文件夹相反,其中只有可直接访问的文件。 我认为将第三方pugins放在自己的文件夹中是有意义的。 我在Public文件夹中没有一些“plugins”文件夹,主要是为了获得更短的网址。 I began to replace Content and Script folders wit ...
  • 你有正确的想法,下面是一个如何通过端点保证安全的例子。 public class MyAuthorizeMiddleware { private readonly RequestDelegate _next; public MyAuthorizeMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { ...
  • 我会用一个单独的服务API来解决这个问题。 上传许多可能很大的文件的任务是一个长期运行的过程,您不希望触摸您的Web应用程序。 这种方法的主要优点是,如果出现问题,它不会影响您的Web应用程序。 如果上载失败,您不希望重新启动Web应用程序以解决此问题。 由于您担心这种方法的可扩展性,我会考虑使用后台任务管理器,这对于这类即发即弃的任务非常适合。 就个人而言,我使用并推荐了Hangfire ,因为它附带了一个漂亮的集成仪表板 ,可让您在运行时观察任务。 它还允许您自动重试失败(可配置),我认为它总体上很适合 ...
  • 如果您要拥有一个网站和一个Web服务,那么我会考虑将数据访问和实体层从MVC中分离出来。 这样,您的Web服务可以执行与您的网站相同的操作。 我会有一个他们都与之交互的服务层。 之后,调用将转到数据库并返回对象,Web服务和网站都不能与此层交互。 这个概念也称为关注点分离 。 您不能/不应该在Web服务中重用MVC控制器。 如果它们非常相似以至于无法区分,那么请考虑将您的网站编写为Web服务的客户端,而不是将其作为同一解决方案的一部分。 If you're going to have a web site ...
  • 我会在www.sourceforge.net或www.codeplex.com上搜索ASP.NET社区项目。 不幸的是,很多这些项目被抛弃或忽视,并且可能会出现不一致的情况。 我更喜欢付费收藏。 如果你把'时间看作钱',我会争辩说,很多这些付费选项最终会比花费更多时间使用的免费收藏更便宜。 更不用说也可能存在支持差异。 许多付费选项都有试用期。 为什么不花一点时间和他们玩,如果你找到一个可以改善你的产品,那就继续购买吧。 前面提到的DevExpress和Telerik有很多东西可以提供(其他供应商也存在)。 ...
  • 啊。 一切都变得清晰了。 这是一个半答案,因为它并没有真正解决问题,但同样问题并不存在! 问题是Roxy Fileman不使用弹出窗口中内置的“上传”选项卡。 它希望用户只能“浏览服务器”并使用Roxy中的“添加文件”链接。 我对说明感到困惑,但现在我明白了! Ah. All has become clear. This is a half and half answer really as it doesn't really solve the problem, but equally the probl ...
  • 您的问题过于通用,无法提供有意义的回复,但大多数情况下,模块都封装在外部类中,该外部类在Web应用程序中引用和注册。 如果您希望能够在运行时包含新模块,可以查看MEF并使用它。 否则,它只是设计您的应用程序,以便它可以从外部程序集实例化类。 Your question is too generic to provide a meaningful reply, but modules in most cases are encapsulated in an external class, which is r ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)