通过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 (将#修改为@)