我在Spring DSL中有以下代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
"
>
<util:list id="decoders" list-class="java.util.LinkedList">
<bean id="length-decoder" class="org.apache.camel.component.netty.ChannelHandlerFactories" factory-method="newLengthFieldBasedFrameDecoder">
<constructor-arg value="5000"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>
</bean>
<bean id="string-decoder" class="org.jboss.netty.handler.codec.string.StringDecoder"/>
</util:list>
<bean id="length-decoder" class="org.apache.camel.component.netty.ChannelHandlerFactories" factory-method="newLengthFieldBasedFrameDecoder">
<constructor-arg value="5000"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>
</bean>
<bean id="string-decoder" class="org.jboss.netty.handler.codec.string.StringDecoder"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="netty:tcp://10.1.33.204:9001?keepAlive=true&decoders=#length-decoder,#string-decoder&disconnect=true" />
<log message="${body}" loggingLevel="INFO"/>
<to uri="direct:SMSRequests"/>
</route>
<route>
<from uri="direct:SMSRequests"/>
<log message="${body}" loggingLevel="INFO"/>
<setBody><simple>0004THIS</simple></setBody> <!--hardcoded response-->
<log message="response --- ${body}" loggingLevel="INFO"/>
</route>
</camelContext>
</beans>
我的输入与1200<XML>....</XML>
类似,其中1200
是以<XML>
开头的邮件的长度。
我的问题是:
答案 0 :(得分:0)
decoders
length-decoder
和/或string-decoder
添加到注册表中,或者您无法在uri中引用它们lengthFieldOffset
(lenght-decoder
的第一个构造函数参数)设置为0