Apache camel 将netty4 tcp端点限制为单个实例

Apache camel 将netty4 tcp端点限制为单个实例,apache-camel,Apache Camel,我在8001有一个模拟端点,它将回显提供给它的任何内容。 我有一个http端点,它将URL的结尾提交给模拟端点,并从端点的响应中提供响应。 那很好 挑战是,我希望http路由只使用一个到8001端点的tcp连接 我创建了一个worker组,如其他地方所述,并将worker count设置为1。通过查看源代码,我认为这种方法应该有效 但是,当我执行此bash命令时: for a in {1..5}; do curl "http://localhost:8080/upstream/REQUESTNU

我在8001有一个模拟端点,它将回显提供给它的任何内容。 我有一个http端点,它将URL的结尾提交给模拟端点,并从端点的响应中提供响应。 那很好

挑战是,我希望http路由只使用一个到8001端点的tcp连接

我创建了一个worker组,如其他地方所述,并将worker count设置为1。通过查看源代码,我认为这种方法应该有效

但是,当我执行此bash命令时:

for a in {1..5}; do curl "http://localhost:8080/upstream/REQUESTNUM$a"  > $a.txt &  done;
我看到到8001的多个连接。我本以为http端点请求必须共享一个池工作程序,但事实似乎并非如此

也许我遗漏了什么,或者也许有另一种方法可以实现我的目标,即对所有http请求只使用一个后端tcp连接

我如何完成它

<?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                                             
<beans xmlns="http://www.springframework.org/schema/beans"                                                                                                                                                         
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                                                                                                                                          
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd                                                                                   
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">                                                                                                                 
    <camelContext                                                                                                                                                                                                  
        xmlns="http://camel.apache.org/schema/spring">                                                                                                                                                             

        <route id="mockUpstream">                                                                                                                                                                                  
            <from                                                                                                                                                                                                  
                uri="netty4:tcp://localhost:8001?sync=true&amp;textline=true&amp;keepAlive=true&amp;disconnect=false&amp;reuseChannel=true" />                                                                     
            <log message="Incoming to upstream: ${body}" />                                                                                                                                                        
            <transform>                                                                                                                                                                                            
                <simple>${body}</simple>                                                                                                                                                                           
            </transform>                                                                                                                                                                                           
        </route>                                                                                                                                                                                                   

        <route id="httpServer">                                                                                                                                                                                    
            <from                                                                                                                                                                                                  
                uri="netty4-http:http://0.0.0.0:8080/upstream?matchOnUriPrefix=true" />                                                                                                                            
            <!-- optional just use CamelHttpQuery from header, for full query -->                                                                                                                                  
            <log                                                                                                                                                                                                   
                message="Incoming http command: ${in.headers[CamelHttpPath]}" />                                                                                                                                   
            <transform>                                                                                                                                                                                            
                <simple>${in.headers[CamelHttpPath]}</simple>                                                                                                                                                      
            </transform>                                                                                                                                                                                           
            <to                                                                                                                                                                                                    
                uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&amp;sync=true&amp;textline=true&amp;keepAlive=true&amp;disconnect=false&amp;reuseChannel=true" />                                         
            <transform>                                                                                                                                                                                            
                <simple>${body}</simple>                                                                                                                                                                           
            </transform>                                                                                                                                                                                           
        </route>                                                                                                                                                                                                   

    </camelContext>                                                                                                                                                                                                

    <bean id="poolBuilder"                                                                                                                                                                                         
        class="org.apache.camel.component.netty4.NettyWorkerPoolBuilder">                                                                                                                                          
        <property name="workerCount" value="1" />                                                                                                                                                                  
    </bean>                                                                                                                                                                                                        

    <bean id="sharedPool" class="io.netty.channel.EventLoopGroup"                                                                                                                                                  
        factory-bean="poolBuilder" factory-method="build"                                                                                                                                                          
        destroy-method="shutdown">                                                                                                                                                                                 
    </bean>                                                                                                                                                                                                        
</beans>  

${body}
${in.headers[CamelHttpPath]}
${body}

通过跟踪级别日志记录查看日志,我看到NettyProducer的池确实设置为使用1个最大活动连接,但允许NettyProducer使用100个空闲连接。I c
   <to                                                                 
        uri="netty4:tcp://localhost:8001?workerGroup=#sharedPool&amp;sync=true&amp;textline=true&amp;keepAlive=true&amp;disconnect=false&amp;reuseChannel=true&amp;producerPoolMaxActive=1&amp;producerPoolMaxIdle=1" />