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

Messages Stuck in Service Broker Queue?

$
0
0

Hi,

Messages get stuck in service broker under conditions that I do not understand.

Client C1 creates new conversation, obtains conversation handle CH1 from server, then does a blocking read which unblocks only when server comes up with more data. Server is to come up with new data numerous times (for days at a time) and report them to client C1 which reads them with those blocking reads. When C1 gets new data it processes the data, then returns to blocking read. The reads are done using the following query:

DECLARE @h UNIQUEIDENTIFIER, @g UNIQUEIDENTIFIER, @t sysname, @b varbinary(MAX)
WAITFOR
(
RECEIVE TOP (1) @h = conversation_handle, @g = conversation_group_id, @t = message_type_name, @b = message_body FROM schema.queue
WHERE conversation_handle = \'CH1\'
),
TIMEOUT -1;
SELECT @h, @g, @t, CONVERT(XML, @b)

Above works fine for a while, then SB decides to keep a message in the queue and C1 does not receive that message until server places yet another message in the queue.

Question #1: Anybody knows how to force messages to 'come out at the other end' without delay? I have read various articles on this where they talk about target queue, and things not being ready at receiving end, etc. In this case, things are always the same at receiving end - a blocking read waiting for data.

Question #2

It is even worse when you have multiple clients on the same server. When I have clients C1 and C2, with corresponding conversation handles CH1 and CH2, both waiting for data as described above, C1 will sometimes not get any data until after server pushes new data to C2, or sends EndDialog message to C2. After C2 receives EndDialog, C1 gets the message long overdue, which was sitting in the queue for a long time. Anybody knows what is going on? What am I missing?

Any thoughts would be greatly appreciated.

Thank you in advance.

Peter


PMBT


Viewing all articles
Browse latest Browse all 461

Trending Articles



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