Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Service Broker Activation Stored Procedure
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 01/31/2014 :  04:30:43  Show Profile  Reply with Quote

I am in a test fase of service broker. I am making use of asynchronous triggers, so my messages are being send from a trigger.
where it goes wrong is when I activate my stored procedure that reads the messages from the queue.
alter queue ....
with activation (
status = on,
execute as self
with this code I set activation status on.

This is stored procedure that is being activated:
declare @message_body as xml;
declare @message_type as sysname;
declare @dialog as uniqueidentifier;

while (1=1)
waitfor (
receive top(1)
@message_type = message_type_name,
@message_body = cast(message_body as xml),
@dialog = conversation_handle
from dbo.MADClaimCallHistoryQueue
), timeout 2000;

if (@@ROWCOUNT = 0)
print 'rowcount = 0'
if (@message_type = '')
end conversation @dialog;
else if (@message_type = '')
print 'Dialog Error dialog #' + cast(@dialog as nvarchar(50));
end conversation @dialog;
else if (@message_type = 'InsertMessage')
print 'convert xml';
insert into MADLog.dbo.SBTest(xmlvar)
select @message_body

end conversation @dialog;

this is just to test, of course this procedure is very simple...

but when activation is off and I execute procedure myself the insert into is done, but when activation is on the insert is not done.

But in both cases message is read from the queue.

My stored procedure is behaving differently, but why? Or is it nog activated? but why than is the message not still on the queue?

Can anyone help me?

  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000