I am having following code in 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>
My input is like 1200<XML>....</XML>
where 1200
is the length of the message starting with <XML>
.
My issues are:
decoders
if you don't reference the set in the urilength-decoder
and/or string-decoder
to the registry or you cannot reference them in the urilengthFieldOffset
(the first constructor parameter of the lenght-decoder
) to 0
if there is no offset