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

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.

相关问答

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

相关文章

更多

最新问答

更多
  • 如何在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)