为什么我的 Camel Netty 路由会在 JMS 消息的开头添加换行符?

编程入门 行业动态 更新时间:2024-10-22 14:39:51
本文介绍了为什么我的 Camel Netty 路由会在 JMS 消息的开头添加换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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&amp;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:关键词]

本文发布于:2023-04-19 22:40:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/971440.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   路由   开头   消息   换行符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!