繁体   English   中英

使用自定义TCP序列化程序的Spring XD

[英]Spring XD Using custom TCP serializer

我扩展了AbstractByteArraySerializer ,现在我想像其他可用的TCP序列化程序(LF,NULL,L1等)一样使用此序列化程序。

我在tcp-encdec.xml找到了配置文件,并注册了自己的配置文件:

...

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

...

Spring使用EncoderDecoderMixins.EncodingEncoding转换为特定的配置文件。

EncoderDecoderMixins.Encoding是最终类中的枚举。 Spring根据此枚举将decoder TCP属性转换为特定的配置文件。 我的CUSTOM序列化程序不起作用,因为它不在指定的Encodings

有没有办法注册新的Encoding还是必须编写一个新的Source模块才能使用我的序列化器?

不幸的是,您将需要一个自定义源。 我们可能会添加另一个枚举,例如CUSTOM ,您在其中提供解串器的类名,但是这需要更改标准源。

一种快速而肮脏的解决方法是在本地修改源:

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

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

即更改${decoder}占位符以指向您的bean。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM