前言:
目前小伙伴们对“nettyhttppipeline”大概比较看重,大家都想要知道一些“nettyhttppipeline”的相关知识。那么小编同时在网上汇集了一些对于“nettyhttppipeline””的相关知识,希望咱们能喜欢,小伙伴们一起来学习一下吧!错误信息
初看的时候还以为是端口占用:Address already in use: bind,不要被错误提示蒙蔽了,实则是 xxl-job 的执行器注解 @Bean 配置的问题。
2020-12-29 09:24:00.494 INFO 9284,// --- [ Thread-40] com.xxl.rpc.remoting.net.Server : >>>>>>>>>>> xxl-rpc remoting server start success, nettype = com.xxl.rpc.remoting.net.impl.netty_http.server.NettyHttpServer, port = 9991Exception in thread "Thread-44" java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550) at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:504) at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:489) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:745)12345678910111213141516171819202122问题定位
在低版本的 xxl-job 中, 初始化 XxlJobSpringExecutor 执行器需要在 @Bean 中加上 initMethod = "start", destroyMethod = "destroy"。
但是在高版本的 xxl-job(如 2.1.2)则需要删除 initMethod = "start", destroyMethod = "destroy"
报错前
@Bean(initMethod = "start", destroyMethod = "destroy")public XxlJobSpringExecutor xxlJobExecutor() { log.info(">>>>>>>>>>> xxl-job config init."); XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses()); xxlJobSpringExecutor.setAppName(jobProperties.getAppName()); xxlJobSpringExecutor.setPort(jobProperties.getPort()); xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath()); xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays()); xxlJobSpringExecutor.setIp(jobProperties.getIp()); xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken()); return xxlJobSpringExecutor;}12345678910111213解决
把 @Bean 的属性 initMethod = "start", destroyMethod = "destroy" 删除即可,代码如下:
@Beanpublic XxlJobSpringExecutor xxlJobExecutor() { log.info(">>>>>>>>>>> xxl-job config init."); XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses()); xxlJobSpringExecutor.setAppName(jobProperties.getAppName()); xxlJobSpringExecutor.setPort(jobProperties.getPort()); xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath()); xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays()); xxlJobSpringExecutor.setIp(jobProperties.getIp()); xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken()); return xxlJobSpringExecutor;
后台私信回复 1024 免费领取 SpringCloud、SpringBoot,微信小程序、Java面试、数据结构、算法等全套视频资料。
标签: #nettyhttppipeline