Readers Not Queued?

Jan 9, 2007

When multiple readers are waiting on a message from the same queue, I would expect that the reader that has been waiting the longest would be the first to pick up a message. However, I'm shocked to discover that the opposite seems to be true; in my tests I'm showing that the reader that has been waiting the least time picks up a message first! This seems totally counter-intuitive, and I'd like to know why it's working this way. This implementation will cause a lot more reader timeouts to occur than a properly queued method. For instance, assume that I have two readers, each using a one minute timeout. Reader #1 starts waiting, and reader #2 is busy for another 20 seconds before it starts waiting. 39 seconds later a message comes in and reader #2 will pick it up, leaving reader #1 to time out one second later! I would much rather have reader #1 pick up the message and reader #2 continue to wait for 20 more seconds.

I'm considering filing a bug on Connect about this, but I thought I'd post here first and see if I can get an answer...

Following is the script I'm using to test:

---Setup / Window #1---

--------------------------------------
CREATE DATABASE SimpleSSB
GO

USE SimpleSSB
GO

--Create a database master key
CREATE MASTER KEY
ENCRYPTION BY PASSWORD = 'onteuhoeu'
GO

--Create a message type
CREATE MESSAGE TYPE Simple_Msg
VALIDATION = EMPTY
GO

--Create a contract based on the message type
CREATE CONTRACT Simple_Contract
(Simple_Msg SENT BY INITIATOR)
GO

--create a queue
CREATE QUEUE Simple_Queue
GO

--Create a service
CREATE SERVICE Simple_Service
ON QUEUE Simple_Queue
(Simple_Contract)
GO
--------------------------------------

---Go start the other windows now---

---Readers: Windows #2-n ---

--------------------------------------
USE SimpleSSB
GO

WAITFOR
(
RECEIVE *
FROM Simple_Queue
), TIMEOUT 300000

--------------------------------------


---Start at least two readers, then do---
--------------------------------------

--send a message...
DECLARE @h UNIQUEIDENTIFIER

BEGIN DIALOG CONVERSATION @h
FROM SERVICE Simple_Service
TO SERVICE 'Simple_Service'
ON CONTRACT Simple_Contract
WITH ENCRYPTION=OFF;

SEND ON CONVERSATION @h
MESSAGE TYPE Simple_Msg
GO

--------------------------------------


... the last reader you've started will pick up the message first. Note I'm testing on 9.0.3033, in case that matters.

Thanks!

View 7 Replies


ADVERTISEMENT

How Can Readers Block Readers In SQL Server 2005

May 26, 2008

Hello All,
Greetings!!!

Due to certain constraints on my Table, I am not able to place unique Key constraint on it.
So I have take care about the uniqueness in my T-SQL code. I don't want to use the serializable transaction isolation level as it will result in frequent deadlocks.
I want some means by which one select will block other select.
Can this be done in SQL Server. I tried using TablockX along with holdlock as Table hint, but still the Selects does not block other select.
Will appreciate if you can resolve this issue

Thanks in Advance,
Mitesh Shah
MCTS- SQL Server 2005

View 4 Replies View Related

Automatic Activation - Message Is Null/Monitoring Of Readers

Nov 29, 2005

I have created a queue with automatic execution of a stored proc with the attribute Max_Queue_Readers = 5.  While processing data, I can select from the queue and see that messages are backed up in the queue.   I have two questions:

View 6 Replies View Related

How To Prevent Table-locking With Multiple Queue Readers

Apr 26, 2007



In a situation where messages are coming in faster than they can be processed, at what point will service broker start up another queue_reader? Also, how do you prevent table locking if part of the processing of that message involves inserting or updating data in a table? We are experiencing this problem because of the high number of messages coming through, and I'm not sure what the best solution is - does service broker have some built-in support for preventing contention on a table when multiple readers are running? Or maybe a pattern that can be used to get around it?

View 1 Replies View Related

Query Queued

Apr 3, 2007

Hi all,I've a problem with sql server 2000 EE.I've a DB with a table with lots of records. I run a SELECT fromquery analyzer, and I've results in 10 seconds. Perfect.When I run the query two times in the same table, seems likeit been queued. Result in 20 seconds.With another query, I've result in 40 seconds. If I run this query 2times, I've results in 80 seconds.How can it be? Does Sql Server queue the query?thanks, and sorry for bad english! :D

View 3 Replies View Related

Queued Tasks

Apr 24, 2008

What command can I issue from query analyzer to list tasks in the queued_tasks table. I would like to see tasks assigned to be run, completed, running, and error.

Thanks

View 5 Replies View Related

Queued Update

Sep 10, 2006

Dear friends

                          I have a simple doubt.

1)What is the difference between  Queued Updating & Immediate Updating in  Transactional  Relplication.

2)What is the difference between Meged Replication & Peer to Peer replication.Because  in both each node will Act as Publisher/Subscriber.So load balancing is possible both type replication na? 

3) how to replicate  views,stored procedure & functions.Beacuse  when applying intial snapshot the copy is getting in subscriber.But afterwards whatever changes occurring in view,procedure not propagating from publisher to subscriber.what to do in this case

                                                                                                                    Filson

View 1 Replies View Related

Email Never Sent Only Shows Mail Queued

Jul 22, 2015

This is my syntax which looks valid to me, but the message will never send, need to get the message to send? (@recipients & @from_address are junk here, but valid email addresses in my procedure)

Code:
exec msdb.dbo.sp_send_dbmail
@profile_name = 'DatabaseMail',
@recipients = 'loggedinuser@domain.com',
@body_format = 'HTML',
@from_address = 'SQLEmailAccount@domain.com',
@body = 'Test 12345',
@subject = 'Test Email From SQL Server';

View 10 Replies View Related

Problem With Queued Updatable Subscriptions

Mar 7, 2008

Hi All,

I have a problem replicating data from Subscriber to Publisher.

I configured Queued updatable subscriptions in transactional replication. Publisher is on SQL Server Standard edition and Subscriber is on SQL Server Express edition, both on Windows XP.

When I insert/update data in publisher, the data is replicated to subscriber. If I insert/update data on subscriber the data is not replicated. When I see the replication monitor for errors, it shows an error "Cannot load a DLL xprepl.dll or one of its resources".

Could any one give me a solution or please tell me if I missing something?

Thanks you all,
Ravi.

View 6 Replies View Related

Transact SQL :: How To Find Mail Is Queued

Jul 19, 2015

I want to send an email twice a day, from database. So I have planned to make a storedproce which will be called by a job (which will select some record from one table and put it in other table based on a flag) but I want to run it in a transaction so that if email is send successfully then only it should commit else it should rollback.

How  can i find that "Mail queued" now i should commit.

View 4 Replies View Related

Sp_send_dbmail Mail Queued. Message

May 2, 2006

I have an After Update Trigger specified on a database table to notify specific users via email when certain customer values are modified. (This is a HACK / Workaround for functionality that doesn't exsist in the product.)

I had be using xp_sendmail without a problem. I recently upgraded the database server to SQL2005 and wanted to try sp_send_dbmail. (I was interested in the asynch and the non-MAPI nature of Database Mail.)

This is the new code:


EXEC @retval = msdb.dbo.sp_send_dbmail


@recipients = @rec,

@blind_copy_recipients = @bcc,

@subject = 'Important Customer Information Change',

@body = @body

This is the old code:


EXEC @retval = master.dbo.xp_sendmail


@recipients = @rec,

@blind_copy_recipients = @bcc,

@subject = 'Important Customer Information Change',

@message = @body

The problem now is that the application reports an update failure because the sp_send_dbmail return the message "Mail Queued."

I don't know if there's a way to suppress this message or not. Or some other way to indicate that "all is well" even though the stored procedure returned a message.

Thanks in advance.

View 6 Replies View Related

Sending Queued Email Using Database Mail

Oct 19, 2006

We have a ASP.Net 2.0 web application and need to send out emails. We have an EmailQueue table in our database where email gets stored before it is send out.  We are looking at the pros and cons of using Database Mail in SQL Server 2005 to send out our emails. Should we use SQL or our web app to send email???Tips, tricks, articles, experiences, opinions are greatly appreciated. Newbie

View 2 Replies View Related

SQL Server 2012 :: How To Find When Email Is Queued

Jul 19, 2015

I want to send an email two ice a day, from database. So I have planned to make a storedproce which will be called by a job (which will select some record from one table and put it in other table based on a flag) but I want to run it in a transaction so that if email is send successfully then only it should commit else it should rollback.

How can i find that "Mail queued" now i should commit.

View 1 Replies View Related

Queued Updating - Missing Insert Proc

Oct 17, 2007

Hi

I'm running transactional repl with updateable subscribtions - queued updating. Running SQL 2005 sp2, win 2003 sp1

I have 18 odd subscribers at the moment, my publisher and disttribution is on the same machine with push subscriptions.

The questions I have

nr 1.
While trying to initialize new subscribers I get loads of deadlocks even after I stop dist cleanup agent. This *I think* cause some other unexpected problems.

nr2.
The queue reader would fail saing it cannot find the "insert" proc on the publisher, although it exists.
I have changed anything on the publication so I'm not sure how this happens or why.

nr3.
I replicate a varbinary(max) column and on the odd occasion get the "Length of LOB data" errors which I then set with sp_configure. The catch here is that the length never exceeds a "len()" of 4000, thus the reported LOB and my calculation doesn't tie up.

Help is appreciated.

Thanks




View 3 Replies View Related

Clarifications On Queue Service And Queue Readers

Jan 11, 2006

Hello,
This is info that I am still not certain about and I just need to make sure, my gut feeling is correct:

A.
When a procedure is triggered upon reception of a message in a queue, what happens when the procedure fails and rolls back?
1. Message is left on the Queue.
2. is the worker procedure triggered again for the same message by the queue?
3. I am hoping the Queue keeps on triggering workers until it is empty.

My scenario is that my queue reader procedure only reads one message at a time, thus I do not loop to receive many messages.

B.
For my scenario messages are independent and ordering does not matter.
Thus I want to ensure my Queue reader procedures execute simultaneously. Is reading the Top message in one reader somehow blocking the queue for any other reader procedures? I.e. if I have BEGIN TRANSACTION when reading messages of the Queue, is that effectively going prevent many reader procedures working simultaneously. Again, I want to ensure that Service broker is effectively spawning procedures that work simultaneously.

Thank you very much for the time,

Lubomir

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved