Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有postgres的Java netty tcp服务器。查询无限期挂起_Java_Spring_Postgresql_Tcp_Netty - Fatal编程技术网

带有postgres的Java netty tcp服务器。查询无限期挂起

带有postgres的Java netty tcp服务器。查询无限期挂起,java,spring,postgresql,tcp,netty,Java,Spring,Postgresql,Tcp,Netty,我在Netty上用tcp服务器编写Spring引导应用程序。服务获取消息并检查postgres数据库中的行。问题在于,在检查数据库中的记录时,服务挂起并停止处理来自tcp通道的其他消息 配置: @Bean public void start() throws InterruptedException { log.info("Starting server at: {} ", tcpPort); EventLoopGroup bossGroup = new N

我在Netty上用tcp服务器编写Spring引导应用程序。服务获取消息并检查postgres数据库中的行。问题在于,在检查数据库中的记录时,服务挂起并停止处理来自tcp通道的其他消息

配置:

 @Bean
public void start() throws InterruptedException {
    log.info("Starting server at: {} ", tcpPort);
    EventLoopGroup bossGroup = new NioEventLoopGroup();
    EventLoopGroup workerGroup = new NioEventLoopGroup();

        ServerBootstrap b = new ServerBootstrap();
        b.group(workerGroup, bossGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(simpleTCPChannelInitializer)
                .childOption(ChannelOption.SO_KEEPALIVE, true);

        // Bind and start to accept incoming connections.
        ChannelFuture f = b.bind(tcpPort).sync();
        if(f.isSuccess())
            log.info("Server started successfully");
        f.channel().closeFuture().sync();

}
通道初始化:

 private final EventExecutorGroup sqlExecutorGroup = new DefaultEventExecutorGroup(16);

protected void initChannel(SocketChannel socketChannel) {
    socketChannel.pipeline().addLast(new StringEncoder());
    socketChannel.pipeline().addLast(new StringDecoder());
    socketChannel.pipeline().addLast(sqlExecutorGroup, simpleTCPChannelHandler);
}
数据库的配置和方法:

    @Override
public void processMessage(String atmRequest) {
        log.info("Receive tcp atmRequest: {}", atmRequest);
        checkDeviceInDatabase(deviceUid);
        log.info("Receive power up command");
}

private void checkDeviceInDatabase(String deviceUid) {
    statusConnectRepository.findById(deviceUid).orElseThrow(()
            -> new DeviceNotFoundException("DeviceUid: " + deviceUid + " was not found in database"));
}
在checkDeviceInDatabase(deviceUid)方法中,查询将永远挂起。 有人遇到过这样的问题吗