Spring integration 编写自己的Spring PayloadTransformer并加载它

Spring integration 编写自己的Spring PayloadTransformer并加载它,spring-integration,citrus-framework,Spring Integration,Citrus Framework,我目前正在使用citrus framework测试一个应用程序。 我的一个接口使用Protobuf,我想实现一个Protobuf-to-json转换器,它与spring integration兼容,类似地使用它,但使用我的转换器,而不是对象到字符串的转换器: <int:channel id="configRawReplies" /> <int:object-to-string-transformer id="configtransformer" input-channel="

我目前正在使用citrus framework测试一个应用程序。 我的一个接口使用Protobuf,我想实现一个Protobuf-to-json转换器,它与spring integration兼容,类似地使用它,但使用我的转换器,而不是对象到字符串的转换器:

<int:channel id="configRawReplies" />

<int:object-to-string-transformer id="configtransformer" input-channel="configRawReplies" output-channel="configResponse" />

<int:channel id="configResponse">
    <int:queue />
</int:channel>
有人有什么想法或提示可以在网上找什么地方吗


BR

没错。您确实需要遵循
ObjectToStringTransformer
中的设计来实现自己的
AbstractPayloadTransformer
。在应用程序上下文中,它必须是一个普通的
定义

唯一的问题是,您不明白为什么我们真的有所有这些自定义标记来利用
输入通道
输出通道
属性。关键是这

例如,
为应用程序上下文提供了几个bean,包括所提到的
objecttoString Transformer
实例、一个
MessageTransformingHandler
以及最后一个
ConsumerdPointFactoryBean
MessageHandler
输入通道连接起来

因此,这里缺少的是自定义
AbstractPayloadTransformer
实现的通用
定义:

<bean id="Proto2Json" class="com.nobody.citrus.transformer.ProtoToJSONString"/>

<int:tranformer ref="Proto2Json" input-channel="configRawReplies" output-channel="configResponse"/>

请阅读更多参考手册,避免将来进行类似讨论:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Proto2Json' defined in URL [file:/Users/nobody/DevOops/test/citrus-scala/target/test-classes/citrus-context.xml]: 
Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: 
Invalid property 'input-channel' of bean class [com.pme.citrus.transformer.ProtoToJSONString]: 
Bean property 'input-channel' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
<bean id="Proto2Json" class="com.nobody.citrus.transformer.ProtoToJSONString"/>

<int:tranformer ref="Proto2Json" input-channel="configRawReplies" output-channel="configResponse"/>