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 MVC(集成第三方控件/组件)?(ASP.NET MVC ready for business applications (integrating 3rd party controls/components)?)

如果他们使用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 th...

将ASP.Net网格数据输出到excel wo第三方dll(Export ASP.Net grid data to excel w.o. third party dll)

我建议你,如果你使用GridView的模板字段中的任何控件像Bullted List,RadioButtonList,CheckBoxList,你想在Excel中导出,因为它只使用以下代码... public void ExportToExcel(GridView gv, string filename) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeade...

ASP.NET的第三方会话状态提供程序(Third party session state provider for ASP.NET)

查看此博客文章 (在帖子的末尾有一个第三方提供商列表,如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).

在ASP.NET MVC中放置第三方插件/库的位置(Where to put third-party plugins/libraries in ASP.NET MVC)

我开始用类似于此的文件夹结构替换Content和Script文件夹: 上市 CSS 脚本 图片 ... 的fancybox markitup 我把它全部放在名为“Public”的文件夹中的原因是,与Views或Controller文件夹相反,其中只有可直接访问的文件。 我认为将第三方pugins放在自己的文件夹中是有意义的。 我在Public文件夹中没有一些“plugins”文件夹,主要是为了获得更短的网址。 I began to replace Content and Script folder...

Asp.net核心WEB API安全的第三方中间件路线?(Asp.net core WEB API secure 3rd party middleware routes?)

你有正确的想法,下面是一个如何通过端点保证安全的例子。 public class MyAuthorizeMiddleware { private readonly RequestDelegate _next; public MyAuthorizeMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) ...

用于将上传传递给第三方的ASP.Net架构(ASP.Net architecture for passing upload to third party)

我会用一个单独的服务API来解决这个问题。 上传许多可能很大的文件的任务是一个长期运行的过程,您不希望触摸您的Web应用程序。 这种方法的主要优点是,如果出现问题,它不会影响您的Web应用程序。 如果上载失败,您不希望重新启动Web应用程序以解决此问题。 由于您担心这种方法的可扩展性,我会考虑使用后台任务管理器,这对于这类即发即弃的任务非常适合。 就个人而言,我使用并推荐了Hangfire ,因为它附带了一个漂亮的集成仪表板 ,可让您在运行时观察任务。 它还允许您自动重试失败(可配置),我认为它总...

ASP.NET MVC和提供第三方API(ASP.NET MVC and Providing Third-Party API)

如果您要拥有一个网站和一个Web服务,那么我会考虑将数据访问和实体层从MVC中分离出来。 这样,您的Web服务可以执行与您的网站相同的操作。 我会有一个他们都与之交互的服务层。 之后,调用将转到数据库并返回对象,Web服务和网站都不能与此层交互。 这个概念也称为关注点分离 。 您不能/不应该在Web服务中重用MVC控制器。 如果它们非常相似以至于无法区分,那么请考虑将您的网站编写为Web服务的客户端,而不是将其作为同一解决方案的一部分。 If you're going to have a web ...

免费的第三方ASP.NET控件集合?(Free third party ASP.NET control collections?)

我会在www.sourceforge.net或www.codeplex.com上搜索ASP.NET社区项目。 不幸的是,很多这些项目被抛弃或忽视,并且可能会出现不一致的情况。 我更喜欢付费收藏。 如果你把'时间看作钱',我会争辩说,很多这些付费选项最终会比花费更多时间使用的免费收藏更便宜。 更不用说也可能存在支持差异。 许多付费选项都有试用期。 为什么不花一点时间和他们玩,如果你找到一个可以改善你的产品,那就继续购买吧。 前面提到的DevExpress和Telerik有很多东西可以提供(其他供应商...

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)

啊。 一切都变得清晰了。 这是一个半答案,因为它并没有真正解决问题,但同样问题并不存在! 问题是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 ...

在ASP.net Web应用程序上启用第三方模块集成[关闭](Enable 3rd Party Module Integration on your ASP.net Web Application [closed])

您的问题过于通用,无法提供有意义的回复,但大多数情况下,模块都封装在外部类中,该外部类在Web应用程序中引用和注册。 如果您希望能够在运行时包含新模块,可以查看MEF并使用它。 否则,它只是设计您的应用程序,以便它可以从外部程序集实例化类。 Your question is too generic to provide a meaningful reply, but modules in most cases are encapsulated in an external class, which...

相关文章

更多

java socket server

用java编写的一个socket服务端,通过一个tcp测试工具测试这个服务端,发现发送数据给服务端,服 ...

Netty入门实例-编写服务器端程序

channelRead()处理程序方法实现如下

Solr Server对外提供Web Service的沟通方式 使用SolrJ跟Solr Server通信

使用SolrJ跟Solr Server通信 郝国梁 (2009年8月 3日 23:09) ...

Hadoop的thrift server配置

说明:Hadoop版本:hadoop-1.2.1.tar.gz。linux系统12.04,不过这里跟系 ...

ubuntu server 安装ssh服务

sudo apt-getinstall openssh-server,Ubuntu缺省安装了opens ...

Netty入门实例-时间服务器

Netty中服务器和客户端之间最大的和唯一的区别是使用了不同的Bootstrap和Channel实现

solr搜索提示,将词添加到词库中

solr wiki: http://wiki.apache.org/solr/Suggester/ 实 ...

HTML5服务器事件发送(Server-Sent Events)【HTML5教程 - 第十三篇】

erver-Sent Events - 单向的信息处理.一个SSE(server send event ...

《Windows Server 2008服务器架设与管理教程(项目式)》扫描版[PDF]

中文名: Windows Server 2008服务器架设与管理教程(项目式) 作者: 丛书编委 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本