36.10. Netty 사장 및 작업자 스레드 풀 재사용
Netty에는 두 종류의 스레드 풀이 있습니다: 사장과 작업자. 기본적으로 각 Netty 소비자 및 생산자에는 개인 스레드 풀이 있습니다. 여러 소비자 또는 생산자 간에 이러한 스레드 풀을 재사용하려면 레지스트리에서 스레드 풀을 생성하고 등록해야 합니다.
예를 들어 Spring XML을 사용하여 다음과 같이 두 개의 작업자 스레드가 있는 NettyWorkerPoolBuilder
를 사용하여 공유 작업자 스레드 풀을 생성할 수 있습니다.
사장 스레드 풀의 경우 Netty consumers를 위한 org.apache.camel.component.netty.netty.nettyServerBossPoolBuilder
빌더와 Netty 생산자의 org.apache.camel.component.nettyClientBossPoolBuilder
가 있습니다.
그런 다음 Camel 경로에서 다음과 같이 URI에 workerPool
옵션을 구성하여 이 작업자 풀을 참조할 수 있습니다.
<route> <from uri="netty:tcp://0.0.0.0:5021?textline=true&sync=true&workerPool=#sharedPool&usingExecutorService=false"/> <to uri="log:result"/> ... </route>
<route>
<from uri="netty:tcp://0.0.0.0:5021?textline=true&sync=true&workerPool=#sharedPool&usingExecutorService=false"/>
<to uri="log:result"/>
...
</route>
그리고 다른 경로가 있으면 공유 작업자 풀을 참조할 수 있습니다.
<route> <from uri="netty:tcp://0.0.0.0:5022?textline=true&sync=true&workerPool=#sharedPool&usingExecutorService=false"/> <to uri="log:result"/> ... </route>
<route>
<from uri="netty:tcp://0.0.0.0:5022?textline=true&sync=true&workerPool=#sharedPool&usingExecutorService=false"/>
<to uri="log:result"/>
...
</route>
기타 등등.