Netty HttpServer api改变/与可用示例不同(Netty HttpServer api changed/differs from available examples)

Arjen Poutsma的博客文章Josh Long的视频示例中的 Netty服务器实例化是通过创建一个reactor.ipc.netty.http.HttpServer实例,然后使用ReactorHttpHandlerAdapter实例作为参数调用它的startstartAndAwait方法来完成的。

然而,API似乎已经改变,因为现在startstartAndAwait方法现在期望具有以下签名的lambda:

java.util.function.Function<? super reactor.ipc.netty.http.HttpChannel,? extends org.reactivestreams.Publisher<java.lang.Void>>

项目依赖项及其版本与Arjen Poutsma的示例项目中的相同

    <dependency>
        <groupId>org.reactivestreams</groupId>
        <artifactId>reactive-streams</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
        <version>3.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>io.projectreactor.ipc</groupId>
        <artifactId>reactor-netty</artifactId>
        <version>0.5.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>8.5.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web-reactive</artifactId>
        <version>5.0.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.2</version>
    </dependency>

使用spring reactor支持实例化netty服务器的新/正确方法是什么?


Netty server instantiation in Arjen Poutsma's blog post and Josh Long's video example is done by creating an reactor.ipc.netty.http.HttpServer instance and then calling it's start or startAndAwait method with an ReactorHttpHandlerAdapter instance as an argument.

However the API seems to have changed as now start and startAndAwait methods now expect a lambda with the following signature:

java.util.function.Function<? super reactor.ipc.netty.http.HttpChannel,? extends org.reactivestreams.Publisher<java.lang.Void>>

Project dependencies and their versions are the same as in Arjen Poutsma's example project

    <dependency>
        <groupId>org.reactivestreams</groupId>
        <artifactId>reactive-streams</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
        <version>3.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>io.projectreactor.ipc</groupId>
        <artifactId>reactor-netty</artifactId>
        <version>0.5.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>8.5.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web-reactive</artifactId>
        <version>5.0.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.2</version>
    </dependency>

What is the new/proper way of instantiating a netty server with spring reactor support?


原文:https://stackoverflow.com/questions/40830340
2023-08-28 12:08

满意答案

我想当我们升级到rails 3.2时我也遇到过这个问题。 我得到的错误是由延迟作业使用的yaml处理程序引起的。 尝试将以下内容添加到config/boot.rb

require 'rubygems'
require 'yaml'
YAML::ENGINE.yamler = 'syck'

Just in case anyone ever runs into this issue. I figured out the cause was some of the jobs were injected with an older version of Delayed Job. So when the newer Delayed Job attempted to process them, it was unable to deserialize the handler.

相关问答

更多

延迟作业反序列化错误,无法加载:分配器未定义为Proc(Delayed Job DeserializationError, failed to load: allocator undefined for Proc)

DelayedJob尝试序列化您调用方法的对象。 在您的情况下,该对象具有IO和Proc对象。 它们都与序列化不兼容。 你能做的最好的事情就是编写一个没有依赖关系的简单包装器,并初始化方法调用中的所有东西。 DelayedJob tries to serialize the object you are calling the method on. In your case, that object has an IO and also a Proc object. Both of them ar...

无法弄清楚onMouseOver(Cannot figure out onMouseOver)

不,这不明显。 JavaScript并不那么容易处理。 您必须了解可以在JavaScript中使用的对象的类型和名称。 对象document没有元素bgcolor 您正在尝试更改文档元素主体的CSS样式 document.body.style.backgroundColor = 'lightgreen'; 可以通过使用您尝试过的文档对象模型(DOM)来实现,但您必须尊重这种情况。 文档属性的正确形式是bgColor而不是bgcolor(大写字母C)。 // bad style document...

无法弄清楚NullPointerException来自哪里(Can't figure out where NullPointerException comes from)

将其替换为您的代码。 public class MainActivity extends ListActivity { DatabaseHelper db; Button knapp1; Button knapp2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main)...

手动重试作业在Delayed_job(Manually Retry Job in Delayed_job)

手动调用作业 Delayed::Job.find(10).invoke_job # 10 is the job.id 如果成功运行,则不会删除该作业。 您需要手动删除它: Delayed::Job.find(10).destroy To manually call a job Delayed::Job.find(10).invoke_job # 10 is the job.id This does not remove the job if it is run successfully. Y...

我无法弄清楚strcpy(I can't figure out strcpy)

c是单个字符,而a是一个字符串(这解释了为什么c只能容纳一个字符,以及编译器为什么抱怨)。 如果你想让c持有一个完整的字符串,那就这样声明它(就像你对sentence所做的那样)。 c is a single character, while a is a string (which explains both why c can only hold a single character, and why the compiler is complaining). If you want c to...

无法弄清楚分段错误(Cant figure out segmentation fault)

如果strtok()返回NULL则需要中断循环。 在回到循环顶部的while测试之前,你不会检查它。 但是为时已晚,因为strtok()之后的代码尝试使用str 。 str = strtok(NULL, " ,.-#\n\t"); if (!str) { break; } You need to break out of the loop if strtok() returns NULL. You're not checking that until you get back to th...

我无法弄清楚这个ConcurrentModificationException(I can't figure out this ConcurrentModificationException)

子列表的javadoc状态: 如果支持列表(即此列表)在结构上以除返回列表之外的任何方式进行修改,则此方法返回的列表的语义将变为未定义。 在您的情况下,您调用subList两次并通过两个子列表修改原始列表。 这是你的例外的来源。 在不改变代码的情况下,您可以简单地制作副本以避免出现此问题: List<Integer> list1 = new LinkedList<> (list.subList(0, pivot)); List<Integer> list2 = new LinkedList<> (...

无法弄清楚Delayed :: DeserializationError(Can't figure out Delayed::DeserializationError)

我想当我们升级到rails 3.2时我也遇到过这个问题。 我得到的错误是由延迟作业使用的yaml处理程序引起的。 尝试将以下内容添加到config/boot.rb require 'rubygems' require 'yaml' YAML::ENGINE.yamler = 'syck' Just in case anyone ever runs into this issue. I figured out the cause was some of the jobs were injected...

无法弄清楚如何创建这个if语句(Cannot figure out how to create this if statement)

这将完成工作: if( $type != '' && $type != 'before' && $type != 'after'){} This'll do the job: if( $type != '' && $type != 'before' && $type != 'after'){}

弄清楚可以抛出的所有可能的异常?(Figure out all possible exceptions that can be thrown?)

不可以。事先原则上你不能知道在运行时CLASSPATH上会出现什么异常类,一开始,也不能提前知道实现你正在查看的接口的可能的类集,或者扩展您正在查看的类并覆盖该方法,除非该类或方法是最终的。 您自己的示例就是一个很好的例子:您正在查看HttpURLConnection ,但它是一个抽象类,并且在运行时出现的实际实现类可能因您的配置而异:使用的HTTP URLStreamHandler类可以重新定义,以便使用一个返回HttpURLConnection的不同实现。 No. You can't know...

相关文章

更多

[Netty 1] 初识Netty

1. 简介 最早接触netty是在阅读Zookeeper源码的时候,后来看到Storm的消息传输层也由 ...

Netty开发环境配置

最新版本的Netty 4.x和JDK 1.6及更高版本

Netty源码分析

Netty提供异步的、事件驱动的网络应用程序框架和工具,用以快速开发高性能、高可靠性的网络服务器和客户 ...

Netty基于流的传输处理

​在TCP/IP的基于流的传输中,接收的数据被存储到套接字接收缓冲器中。不幸的是,基于流的传输的缓冲器 ...

Netty入门实例-时间服务器

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

在Twitter,Netty 4 GC开销降为五分之一

原文:http://www.infoq.com/cn/news/2013/11/netty4-twit ...

Netty环境配置

netty是一个java事件驱动的网络通信框架,也就是一个jar包,只要在项目里引用即可。

storm学习之Netty代替ZMQ

整理自 http://www.csdn.net/article/2014-08-04/2821018/ ...

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

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

利用SolrJ操作solr API完成index操作

使用SolrJ操作Solr会比利用httpClient来操作Solr要简单。SolrJ是封装了http ...

最新问答

更多

获取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}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本