SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

MCPieters
Starting Member

Netherlands
3 Posts

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

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:
as
declare @message_body as xml;
declare @message_type as sysname;
declare @dialog as uniqueidentifier;

while (1=1)
begin
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)
begin
print 'rowcount = 0'
break;
end
if (@message_type = 'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog')
end conversation @dialog;
else if (@message_type = 'http://schemas.microsoft.com/SQL/ServiceBroker/Error')
begin
print 'Dialog Error dialog #' + cast(@dialog as nvarchar(50));
end conversation @dialog;
end
else if (@message_type = 'InsertMessage')
begin
print 'convert xml';
insert into MADLog.dbo.SBTest(xmlvar)
select @message_body

end conversation @dialog;
end
end

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?

Thanx
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000