Logging 在Spring集成中使用MarshallingMessageConverter时记录XML有效负载;s Amqp内置适配器
我有Logging 在Spring集成中使用MarshallingMessageConverter时记录XML有效负载;s Amqp内置适配器,logging,spring-integration,spring-integration-amqp,Logging,Spring Integration,Spring Integration Amqp,我有IntegrationFlow,它监听AMQP消息,我想记录XML消息负载 IntegrationFlows.from( Amqp.inboundAdapter(rabbitConnectionFactory, QUEUE) .messageConverter(new MarshallingMessageConverter(xmlMarshaller)) ) .log(INFO, "org.springframework.amqp"
IntegrationFlow
,它监听AMQP消息,我想记录XML消息负载
IntegrationFlows.from(
Amqp.inboundAdapter(rabbitConnectionFactory, QUEUE)
.messageConverter(new MarshallingMessageConverter(xmlMarshaller))
)
.log(INFO, "org.springframework.amqp")
...
.get();
当我在Amqp.inboundAdapter()
中使用MarshallingMessageConverter
时,在.log()
步骤中记录已经反序列化的对象而不是XML负载
我可以使用默认的SimpleMessageConverter
和explicit.transform()
步骤来解决这个问题
有没有一种方法可以记录原始XML负载并继续使用
MarshallingMessageConverter
?其中一种方法是将MessagePostProcessor
添加到侦听器容器中:
Amqp.inboundAdapter(rabbitConnectionFactory, QUEUE)
.messageConverter(new MarshallingMessageConverter(xmlMarshaller))
.configureContainer(container ->
container.afterReceivePostProcessors(message ->
logger.info(new String(message.getBody()))))
当然,另一种方法是在调用
super.fromMessage()
之前,扩展MarshallingMessageConverter
并重写其fromMessage(messagemessage Message)
,以记录正文,其中一种方法是在侦听器容器中添加MessagePostProcessor
:
Amqp.inboundAdapter(rabbitConnectionFactory, QUEUE)
.messageConverter(new MarshallingMessageConverter(xmlMarshaller))
.configureContainer(container ->
container.afterReceivePostProcessors(message ->
logger.info(new String(message.getBody()))))
当然,另一种方法是扩展MarshallingMessageConverter
,并在调用super.fromMessage()
之前重写其fromMessage(Message Message)
以记录正文