为什么我的Camel Netty路由在我的JMS消息的开头添加换行符? [英] Why is my Camel Netty route adding newlines to the start of my JMS messages?

查看:153
本文介绍了为什么我的Camel Netty路由在我的JMS消息的开头添加换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Camel Netty路由,该路由将XML发送到服务器端口,并将其放置在JMS消息中.在第一条消息之后,每条其他消息在消息顶部都有一个换行符,导致GUI收到XML时无法取消编组.

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:my.company.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 |用于文本行编解码器的定界符.可能的值为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆