socket服务如何与netty的http服务兼容

mash5_paul 2017-07-27 11:59:29
介绍:
公司是做通信项目的,功能模块划分大致这样。
终端设备<---------->服务平台<------------>监管平台
需求
监管平台通过http请求下发某个指令到服务平台再通过服务平台转发给终端设备。
然而服务平台是用的java.net.Serversocket写的的,服务平台与监管平台之间是没有链接的(通过扫库的方式把制定指令下发)
弊端:扫库这种方式数据量小还好,大了很慢。(我们用的非内存数据库)
解决方式:在服务平台新增Http服务(服务平台发布方式是一个个jar包发布的),首先想到了当前比较火的netty,netty支持多种decode & encode很方便

遇到的问题:
netty写的http服务开启的时候,原先的所有的socket服务都没有开启(好几个socket服务)。
然后尝试了关闭netty写的http服务一切启动正常,看了http服务启动日志,没什么严重的错误。
想请问大家有没有遇到过类似的问题。

下面是netty的日志:
2017-07-27 11:21:45,910 [DEBUG] io.netty.util.internal.logging.InternalLoggerFactory - Using Log4J as the default logging framework
2017-07-27 11:21:45,912 [DEBUG] io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 32
2017-07-27 11:21:45,924 [DEBUG] io.netty.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
2017-07-27 11:21:45,934 [DEBUG] io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
2017-07-27 11:21:45,935 [DEBUG] io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
2017-07-27 11:21:45,935 [DEBUG] io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
2017-07-27 11:21:45,936 [DEBUG] io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
2017-07-27 11:21:45,936 [DEBUG] io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
2017-07-27 11:21:45,936 [DEBUG] io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
2017-07-27 11:21:45,937 [DEBUG] io.netty.util.internal.Cleaner0 - java.nio.ByteBuffer.cleaner(): available
2017-07-27 11:21:45,937 [DEBUG] io.netty.util.internal.PlatformDependent - Java version: 6
2017-07-27 11:21:45,938 [DEBUG] io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
2017-07-27 11:21:45,938 [DEBUG] io.netty.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
2017-07-27 11:21:45,938 [DEBUG] io.netty.util.internal.PlatformDependent - Javassist: unavailable
2017-07-27 11:21:45,938 [DEBUG] io.netty.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes. Please check the configuration for better performance.
2017-07-27 11:21:45,939 [DEBUG] io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
2017-07-27 11:21:45,939 [DEBUG] io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
2017-07-27 11:21:45,939 [DEBUG] io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
2017-07-27 11:21:45,939 [DEBUG] io.netty.util.internal.PlatformDependent - io.netty.maxDirectMemory: 3746955264 bytes
2017-07-27 11:21:45,973 [DEBUG] io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
2017-07-27 11:21:45,973 [DEBUG] io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
2017-07-27 11:21:45,974 [DEBUG] io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
2017-07-27 11:21:46,020 [DEBUG] io.netty.channel.DefaultChannelId - -Dio.netty.processId: 18660 (auto-detected)
2017-07-27 11:21:46,022 [DEBUG] io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
2017-07-27 11:21:46,022 [DEBUG] io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
2017-07-27 11:21:46,025 [DEBUG] io.netty.util.NetUtil - Loopback interface: lo (lo, 0:0:0:0:0:0:0:1%1)
2017-07-27 11:21:46,026 [DEBUG] io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 128
2017-07-27 11:21:46,028 [DEBUG] io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 00:0c:29:ff:fe:30:aa:fa (auto-detected)
2017-07-27 11:21:46,030 [DEBUG] io.netty.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier: 0x4ed9e18c8d2f21c9
2017-07-27 11:21:46,039 [DEBUG] io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
2017-07-27 11:21:46,039 [DEBUG] io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.maxRecords: 4
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 32
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 32
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
2017-07-27 11:21:46,065 [DEBUG] io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
2017-07-27 11:21:46,078 [DEBUG] io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
2017-07-27 11:21:46,078 [DEBUG] io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536
2017-07-27 11:21:46,078 [DEBUG] io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384

...全文
682 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
X元素 2017-12-13
  • 打赏
  • 举报
回复
楼主注意一下,netty server的启动是阻塞的,

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧