Netty HttpServer api改变/与可用示例不同(Netty HttpServer api changed/differs from available examples)
Arjen Poutsma的博客文章和Josh Long的视频示例中的 Netty服务器实例化是通过创建一个
reactor.ipc.netty.http.HttpServer
实例,然后使用ReactorHttpHandlerAdapter
实例作为参数调用它的start
或startAndAwait
方法来完成的。然而,API似乎已经改变,因为现在
start
和startAndAwait
方法现在期望具有以下签名的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'sstart
orstartAndAwait
method with anReactorHttpHandlerAdapter
instance as an argument.However the API seems to have changed as now
start
andstartAndAwait
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
最满意答案
我想当我们升级到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)[2022-04-17]
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 are not ... -
无法弄清楚onMouseOver(Cannot figure out onMouseOver)[2023-12-17]
不,这不明显。 JavaScript并不那么容易处理。 您必须了解可以在JavaScript中使用的对象的类型和名称。 对象document没有元素bgcolor 您正在尝试更改文档元素主体的CSS样式 document.body.style.backgroundColor = 'lightgreen'; 可以通过使用您尝试过的文档对象模型(DOM)来实现,但您必须尊重这种情况。 文档属性的正确形式是bgColor而不是bgcolor(大写字母C)。 // bad style document.bgCo ... -
将其替换为您的代码。 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.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. You ne ...
-
我无法弄清楚strcpy(I can't figure out strcpy)[2024-04-02]
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 hold ... -
无法弄清楚分段错误(Cant figure out segmentation fault)[2023-03-26]
如果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 the whi ... -
我无法弄清楚这个ConcurrentModificationException(I can't figure out this ConcurrentModificationException)[2022-08-24]
子列表的javadoc状态: 如果支持列表(即此列表)在结构上以除返回列表之外的任何方式进行修改,则此方法返回的列表的语义将变为未定义。 在您的情况下,您调用subList两次并通过两个子列表修改原始列表。 这是你的例外的来源。 在不改变代码的情况下,您可以简单地制作副本以避免出现此问题: Listlist1 = new LinkedList<> (list.subList(0, pivot)); List list2 = new LinkedList<> (list. ... -
我想当我们升级到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 ...
-
这将完成工作: if( $type != '' && $type != 'before' && $type != 'after'){} This'll do the job: if( $type != '' && $type != 'before' && $type != 'after'){}
-
不可以。事先原则上你不能知道在运行时CLASSPATH上会出现什么异常类,一开始,也不能提前知道实现你正在查看的接口的可能的类集,或者扩展您正在查看的类并覆盖该方法,除非该类或方法是最终的。 您自己的示例就是一个很好的例子:您正在查看HttpURLConnection ,但它是一个抽象类,并且在运行时出现的实际实现类可能因您的配置而异:使用的HTTP URLStreamHandler类可以重新定义,以便使用一个返回HttpURLConnection的不同实现。 No. You can't know in p ...