Quantcast
Channel: SQL Service Broker forum
Viewing all articles
Browse latest Browse all 461

Error using RECEIVE with xml

$
0
0

I have a Stored procedure that acts upon a queue with the following code:

DECLARE @message_body as XML, @MessageTypeName as varchar(256), @ConversationHandle as UniqueIdentifier

WAITFOR (RECEIVE TOP (1)  @MessageTypeName = message_type_name

,@message_body = message_body

,@ConversationHandle = Conversation_Handle

FROM MyQueue

), TIMEOUT 5000;

This works well for 90% of the messages in the queue, but bugs out the other 10% of the time. The SQL Log error message being:

The activated proc '[dbo].[usp_ReadMyQueue]' running on queue 'DBName.dbo.MyQueue' output the following:  'XML parsing: line 1, character 519, illegal xml character'

When I checked the message_body for the message causing the error, I found that the character position was represented by a character: ã

I therefore changed the code by adding a new variable @message_body2 as varchar(max), and placing that inside the RECEIVE statement, thus:

.....

,@message_body2 = message_body

......

and following this I added the next line after the TIMEOUT being:

SET @message_body = CAST(@message_body2 as XML)

It all works perfectly well.

My question is why would an xml error be raised in the RECEIVE statement when it is not outside of that statement?

I did try using ,@message_body = CAST(message_body as xml) but that also errored out the same as before.

Just being curious as to whether this should be expected behaviour, or a little-known bug.

Thanks, 


Viewing all articles
Browse latest Browse all 461

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>