gpt4 book ai didi

java - stomp 内容类型 header 设置为 plain 用于 xml 内容

转载 作者:行者123 更新时间:2023-11-29 06:07:34 24 4
gpt4 key购买 nike

我正在使用 stomp 从 ruby​​ 脚本向 ActiveMQ 发送 XML 内容

我明确地将内容类型 header 设置为 application/xml;charset=utf-8,如下所示

client.publish queue, xml, {'content-type'=>'application/xml;charset=utf-8'}

但是当我从使用 spring-integration 读取消息的 java 客户端读取消息时,内容类型是文本/纯文本。

结果,当调用解码器时,解析失败并出现异常

1448446 [org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] WARN org.springframework.jms.listener.DefaultMessageListenerContainer - Execution of JMS message listener failed
org.springframework.integration.transformer.MessageTransformationException: failed to transform message payload
at org.springframework.integration.transformer.AbstractPayloadTransformer.transform(AbstractPayloadTransformer.java:40)
at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:49)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:91)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:59)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:116)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:94)
at org.springframework.integration.channel.MessageChannelTemplate.doSend(MessageChannelTemplate.java:223)
at org.springframework.integration.channel.MessageChannelTemplate.send(MessageChannelTemplate.java:180)
at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:76)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:59)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:116)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:94)
at org.springframework.integration.channel.MessageChannelTemplate.doSend(MessageChannelTemplate.java:223)
at org.springframework.integration.channel.MessageChannelTemplate.send(MessageChannelTemplate.java:180)
at org.springframework.integration.channel.MessageChannelTemplate.send(MessageChannelTemplate.java:168)
at org.springframework.integration.jms.ChannelPublishingJmsMessageListener.onMessage(ChannelPublishingJmsMessageListener.java:203)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.integration.core.MessagingException: Failed to create Source for payload type [[B]
at org.springframework.integration.xml.source.DomSourceFactory.createSource(DomSourceFactory.java:62)
at org.springframework.integration.xml.transformer.XmlPayloadUnmarshallingTransformer.transformPayload(XmlPayloadUnmarshallingTransformer.java:91)
at org.springframework.integration.transformer.AbstractPayloadTransformer.transform(AbstractPayloadTransformer.java:33)
... 30 more

可能是什么问题

最佳答案

找到答案,它的标题 suppress_content_length添加这个让它工作

:suppress_content_length => true

关于java - stomp 内容类型 header 设置为 plain 用于 xml 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8068491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com