Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Service Broker / January 2006

Tip: Looking for answers? Try searching our database.

Priority Queues

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wells Caughey - 26 Jan 2006 20:07 GMT
I would like to use SSB to create priority queues so that I can process some
messages before other messages.  I am currently thinking that I am going to
have to pre-create a number of dialogs between the the intiator and the
receiver, and create conversation groups for each dialog (one per priority
level).  Then in my receiving service do something like the following:

declare @message varbinary(max)

while(true)
begin

   set @message = null

   receive top 1 @message=message_body from Queue where
conversation_group_id=@groupPriority1

   if @message is not null
   begin
       /* process message */
       continue
   end

   /* Do the same but for other priorities here */

   wait for(receive top 1 @message=message_body from Queue)
   /* process message */

end

Is there a better way to do this?  Will this technique effectively serialize
all receive operations by priority?

Thanks,
Wells
Roger Wolter[MSFT] - 26 Jan 2006 20:57 GMT
The main issue I see here is that you are doing a waitfor receive at the end
and you could get a low priority message there.  If that's not an issue, it
should work.  Most people use different queue for different priorities which
is easier to manage because you don't have to mess with getting the dialogs
into the right conversation groups.  Doing receives without a where clause
is also more efficient but the difference isn't huge.
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

>I would like to use SSB to create priority queues so that I can process
>some messages before other messages.  I am currently thinking that I am
[quoted text clipped - 31 lines]
> Thanks,
> Wells
Wells Caughey - 30 Jan 2006 14:13 GMT
You're right, using multiple queues does make more sense.

Thanks for you help,
Wells

> The main issue I see here is that you are doing a waitfor receive at the
> end and you could get a low priority message there.  If that's not an
[quoted text clipped - 38 lines]
>> Thanks,
>> Wells
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.