Git Product home page Git Product logo

Comments (4)

gotZ9 avatar gotZ9 commented on May 21, 2024 2

我的想法是将 EventLoopGroup 对象转由外部提供, 也可以自己创建. RpcServer 再实现 DisposableBean 接口.

@Override
public void afterPropertiesSet() throws Exception {
    if (bossGroup == null) {
        bossGroup = new NioEventLoopGroup();
        bossInitializer = true;
    }
    if (workerGroup == null) {
        workerGroup = new NioEventLoopGroup();
        workerInitializer = true;
    }
    // 略...
}

@Override
public void destroy() throws Exception {
    closeFuture.sync();
    if (bossInitializer) {
        bossGroup.shutdownGracefully();
    }
    if (workerInitializer) {
        workerGroup.shutdownGracefully();
    }
}

from nettyrpc.

luxiaoxun avatar luxiaoxun commented on May 21, 2024

个人并不喜欢spring那套东西,server的启动完全可以不用spring。
加了一个类RpcBootstrapWithoutSpring来说明如何不用spring来启动server,代码仅用来学习。

from nettyrpc.

bugmakesprogress avatar bugmakesprogress commented on May 21, 2024

如果用的是springboot的话,有个更简单的办法: 实现CommandLineRunner接口,在spring的上下文初始化之后回调该接口,实现netty server的初始化.不注意的话我也在这栽了跟头~

from nettyrpc.

luxiaoxun avatar luxiaoxun commented on May 21, 2024

已通过一个启动线程来解决该问题

from nettyrpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.