问题描述
限时送ChatGPT账号..我有一个 Camel Netty 路由,它将 XML 发送到服务器端口并将其放置在 JMS 消息中.在第一条消息之后,所有其他消息的顶部都有一个换行符,导致我的 XML 在 GUI 收到它时无法解组.
I have a Camel Netty route that takes XML sent to a server port and places it in a JMS message. After the first message, every other message has a newline at the top of the message, causing my XML to fail to unmarshall when a GUI receives it.
我的路线如下:
<route>
<from uri="netty4:tcp://localhost:5150?decoders=#customFrameDelimeterDecoder,#string-decoder&encoder=#string-encoder"/>
<to uri="jms:topic:mypany.topic"/>
</route>
注意:XML 没有换行终止,因此需要自定义帧分隔符解码器.
Note: The XML is not newline terminated, hence the need for a custom frame delimeter decoder.
推荐答案
尝试设置:
<from uri="netty4:tcp://localhost:5150?textline=true&delimiter=NULL"/>
问题在于 camel-netty4
是 由于编解码器文本而在您的消息中添加分隔符,因此它似乎放置了一个空字符串在您的消息末尾.
The problem is that camel-netty4
is adding a delimiter to your message because of the codec text, so it seems that it is putting a empty string at the end of your message.
您也可以尝试将 autoAppendDelimiter
添加到 false.根据文档:
You could also try to add autoAppendDelimiter
to false. According to docs:
分隔符 |线 |用于文本行编解码器的分隔符.可能的值是 LINE 和 NULL
delimiter | LINE | The delimiter to use for the textline codec. Possible values are LINE and NULL
autoAppendDelimiter |真实|使用文本行编解码器发送时是否自动附加缺少的结束分隔符.
autoAppendDelimiter | true | Whether or not to auto append missing end delimiter when sending using the textline codec.
干杯!
抱歉,我正在尝试回答您标记为重复的另一个问题.但也许这个答案也适合.让我知道.
Sorry, I was trying to answer your other question that was marked as duplicated. But maybe this answer also fits. Let me know.
这篇关于为什么我的 Camel Netty 路由会在 JMS 消息的开头添加换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论