データベースに複数の SQL Service Broker キューをセットアップしましたが、この問題はこれまで見たことがありません。XML を含むメッセージが、ほとんどが漢字のように見えるものに変換されています。メッセージ キューに入れる前に、XML を格納している変数を確認すると、英語であり、適切に XML 形式であることがわかります。キューから選択すると、漢字が表示されます。これらの文字は、外部の C# アプリケーションを使用してキューからプルしたときに受け取るものでもあります。奇妙なことに、DBArtisan を使用してキューを表示すると、整形式の XML が表示されます。
以下の XML をキューに配置すると、以下の漢字に変換されます。
<?xml version="1.0" ?>
<Message>
<MachineName>The Super Duper Machine</MachineName>
<CollectionName>snl0013d</CollectionName>
<Action>Install</Action>
<EntryDateTime>Jul 9 2009 4:47PM</EntryDateTime>
</Message>
㼼浸敶獲潩㵮ㄢ〮•㸿†††䴼獥慳敧ാ
†††㰠慍档湩乥浡㹥桔畓数畄数慍档湩㱥䴯捡楨敮慎敭ാ
†††㰠潃汬捥楴湯慎敭猾汮〰㌱㱤䌯汯敬瑣潩乮浡㹥
††††䄼瑣潩㹮湉瑳污㱬䄯瑣潩㹮
††††䔼瑮祲慄整楔敭䨾汵†‹〲㤰†㨵〱䵐⼼湅牴䑹瑡呥浩㹥
†††⼼敍獳条㹥
以下は、メッセージをキューに入れて選択するために使用している T-SQL です。
declare @dialog_handle uniqueidentifier
,@msg varchar(max)
,@collection_name varchar(30)
set @collection_name = 'snl0013d'
set @msg =
N'<?xml version="1.0" ?>
<Message>
<MachineName>' + 'The Super Duper Machine' + '</MachineName>
<CollectionName>' + @collection_name + '</CollectionName>
<Action>' + 'Install' + '</Action>
<EntryDateTime>' + CAST(getdate() AS VARCHAR(100)) + '</EntryDateTime>
</Message>'
select @msg
set @dialog_handle = NEWID()
begin dialog conversation @dialog_handle
from service [SAPP_QUEUE_ResponseService]
to service 'SAPP_QUEUE_SubmitService'
on contract [SAPP_CONTRACT_Contract]
with encryption = off;
send on conversation @dialog_handle
message type [SAPP_MSG_MessageType]
(
@msg
);
end conversation @dialog_handle
with cleanup
select message_body
,conversation_handle
,CONVERT(nvarchar(max), message_body) as msg
from SAPP_QUEUE_SubmitQueue;