1

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

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

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

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

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

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

可能是什么问题呢

4

1 回答 1

3

找到了答案,它的标题suppress_content_length 添加它使它工作

:suppress_content_length => true

于 2011-11-09T18:19:20.083 回答