Spring XD Using custom TCP serializer

折月煮酒 提交于 2019-12-13 02:07:37

问题


I extended AbstractByteArraySerializerand now I want to use this serializer like the rest of the available TCP serializers (LF, NULL, L1, ...).

I found the profiles in tcp-encdec.xml and registered my own profile:

...

<beans profile="use-custom">
    <bean id="CUSTOM"
        class="custom.tcp.serializer.ByteArrayCustomSerializer">
        <property name="maxMessageSize" value="${bufferSize}" />
    </bean>
</beans>

...

Spring uses EncoderDecoderMixins.Encoding to convert Encoding to a specific profile.

EncoderDecoderMixins.Encoding is an enum in a final class. Spring converts the decoder TCP property to a specific profile based on this enum. My CUSTOM serializer won't work since it isn't in the specified Encodings.

Is there a way to register a new Encoding or do I have to write a new Source module to use my serializer?


回答1:


Unfortunately, you will need a custom source; we could probably add another enumeration, such as CUSTOM, where you provide the classname of the deserializer but that will need a change to the standard source.

A quick and dirty work-around would be to modify the source locally:

<int-ip:tcp-connection-factory id="connectionFactory"
    ...
    deserializer="myDeserializer"/>

<bean id="myDeserializer" class="foo.Deser" />

i.e. change the ${decoder} placeholder to point to your bean.



来源:https://stackoverflow.com/questions/35554870/spring-xd-using-custom-tcp-serializer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!