微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过Service Broker传输带有特殊字符的SQL Server xml消息

如何解决通过Service Broker传输带有特殊字符的SQL Server xml消息

我无法通过Service broker将具有特殊字符的xml消息从一个sql Server实例传输到另一个sql Server实例。正常的消息应该可以正常运行,但是带有特殊字符(如“”)的消息不会将完整的消息发送到接收者队列,接收者队列只有部分消息,即直到字符“”之后。如何处理特殊字符?

<transaction>
    <transaction_message>
        <row record="889947009" message="There are “Untaken Rights” in the system "/>
    </transaction_message>  
</transaction>

下面是接收方的代码

WAITFOR
(
    RECEIVE TOP(1)
    @hConversation= conversation_handle,@msgTypeName  = message_type_name,@error_msg    = CASE WHEN message_type_name = N'http://schemas.microsoft.com/sql/Servicebroker/Error'
                                                                    THEN CAST(message_body AS varchar(max))
                                                                    ELSE NULL
                                                               END,@msg          = CASE WHEN message_type_name = N'http://schemas.microsoft.com/sql/Servicebroker/Error'
                                                                    THEN NULL
                                                                    ELSE CAST(message_body AS varchar(max))
    END

    FROM my_queue_name 
),TIMEOUT @receive_time;

sql Server日志中还显示以下消息。该spid与服务代理相关联。

2020-10-12 12:45:32.28 spid30s     An exception occurred while enqueueing a message in the target queue. Error: 7102,State: 99. Internal Error: Text manager cannot continue with current statement. Run DBCC CHECKTABLE.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。