Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging 在Spring集成中使用MarshallingMessageConverter时记录XML有效负载;s Amqp内置适配器_Logging_Spring Integration_Spring Integration Amqp - Fatal编程技术网

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)
以记录正文