Commit c254431b authored by dwentzel's avatar dwentzel

updating code and documentation

parent 44b3b968
ServiceBrokerEnable.sql
-----------------------
http://www.davewentzel.com/content/service-broker-setup-routine. Setting up Service Broker can be daunting for a SB noob. This script handles a lot of the confusion, especially around when to ENABLE_BROKER vs NEW_BROKER.
ServiceBrokerMonitor.sql
-------------------------
http://www.davewentzel.com/content/service-broker-monitoring-routine. For a noob, SB can be daunting. Especially when debugging. This script will help a bit, showing you the current status of your SB infrastructure. This will tell you:
- if your db is_broker_enabled
- looks for dropped queue monitors
- queues sitting in the NOTIFIED state for long periods of time. (means that the Q activator is firing, but proper RECEIVEs are not occurring)
- activated queues that are disabled (could mean the activated proc is throwing errors).
- poison message detection
- Conversation Population Explosion...conversations may not be properly moving to the CLOSED state. This usually happens when the target is not ending the conversation properly.
- display the contents of queues for visual inspection
- display various PerfMon metrics such as Activation Errors Total and Task Limit Reached.
- display the last hour of SQL Server error logs, looking for activator procedure errors and PRINT statements
- runs ssbdiagnose against your queues
- there is a section to place custom TRACER TOKEN code. You need to code this. This would be similar to replication's tracer token feature. Essentially you code a "test" message that flows through your workflow and you monitor it to see if it runs to completion and if not where it failed.
- has an option for STALLED MESSAGE CLEANOUT. This removes old conversations that you deem as not needed that are not in the CLOSED state. This is useful in dev envs where you changed some activator code and the queues failed and there are a bunch of useless messages. Probably not good to run this on a production db.
Contents of Repo
ServiceBrokerEnable.sql : http://www.davewentzel.com/content/service-broker-setup-routine.
Setting up Service Broker can be daunting for a SB noob. This script
handles a lot of the confusion, especially around when to ENABLE_BROKER
vs NEW_BROKER.
ServiiceBrokerMonitor.sql : http://www.davewentzel.com/content/service-broker-monitoring-routine. For a
noob, SB can be daunting. Especially when debugging. This script will
help a bit, showing you the current status of your SB infrastructure.
\ No newline at end of file
......@@ -83,19 +83,11 @@ EXEC (@exec_str)
--check the tickler
--since we possibly issued a SET NEW_BROKER we have to worry about tickling dying. SET NEW_BROKER clears all messages and conversations
--in all queues
--we first need to see if the Tickler procedure is available. We may be enabling SB before delivering the tickler and we don't need this failing.
IF EXISTS (select * from sys.objects where name = 'WL_ConfigureAll')
BEGIN
EXEC WL_ConfigureAll @Option = 'SETUP';
END;
END;
GO
GRANT EXECUTE ON dbo.ServiceBrokerEnable to SiemensUser
GRANT EXECUTE ON dbo.ServiceBrokerEnable to public;
GO
--EXEC ServiceBrokerEnable;
GO
\ No newline at end of file
......@@ -91,27 +91,20 @@ BEGIN
DECLARE @Warnings int
SELECT @Warnings = 0
--stop tickling, if we can
IF EXISTS (select * from sys.service_queues WHERE name = 'WLWklstQueueTicklerQ')
BEGIN
IF EXISTS (select * from sys.objects WHERE name = 'WLWklstQueueTicklerStopTickling')
BEGIN
EXEC WLWklstQueueTicklerStopTickling;
END;
END;
--calls to stop and remove queues go here.
--check to see if there is unprocessed data in any of the Qs and warn accordingly.
IF EXISTS (select * from sys.service_queues WHERE name = 'WLWklstQueueTicklerQ')
IF EXISTS (select * from sys.service_queues WHERE name = 'xxx')
BEGIN
IF EXISTS (select * from [WLWklstQueueTicklerQ])
IF EXISTS (select * from [xxx])
BEGIN
SELECT @Warnings = 1
END;
END;
IF EXISTS (select * from sys.service_queues WHERE name = 'WLWklstQueueTicklerQ')
IF EXISTS (select * from sys.service_queues WHERE name = 'xxx')
BEGIN
IF EXISTS (select * from [WLWklstIBUQ])
IF EXISTS (select * from [xxx])
BEGIN
SELECT @Warnings = 1
END;
......@@ -128,41 +121,10 @@ BEGIN
RETURN 1
END;
--Tickler stuff
IF EXISTS (select * from sys.services WHERE name = 'WLWklstQueueTicklerSvc')
BEGIN
DROP SERVICE [WLWklstQueueTicklerSvc]
END;
IF EXISTS (select * from sys.service_queues WHERE name = 'WLWklstQueueTicklerQ')
BEGIN
DROP QUEUE [WLWklstQueueTicklerQ]
END;
--IBUQ stuff
IF EXISTS (select * from sys.services WHERE name = 'WLWklstIBUSvc')
BEGIN
DROP SERVICE [WLWklstIBUSvc]
END;
IF EXISTS (select * from sys.service_queues WHERE name = 'WLWklstIBUQ')
BEGIN
DROP QUEUE [WLWklstIBUQ]
END;
IF EXISTS (select * from sys.service_contracts where name = 'WLWklstIBUContract')
BEGIN
DROP CONTRACT WLWklstIBUContract
END;
IF EXISTS (select * from sys.service_message_types where name = 'WLWklstIBUMT')
BEGIN
DROP MESSAGE TYPE WLWklstIBUMT
END;
--general SB cleanup stuff
IF EXISTS (select * from sys.conversation_endpoints WHERE far_service IN ('WLWklstIBUSvc','WLWklstQueueTicklerSvc') AND state_desc <> 'CLOSED')
IF EXISTS (select * from sys.conversation_endpoints WHERE far_service IN ('xxx') AND state_desc <> 'CLOSED')
BEGIN
RAISERROR ('sys.conversation_endpoints has non-CLOSED conversations that will need to be ENDed with CLEANUP.',16,1)
END;
......@@ -203,6 +165,7 @@ BEGIN
--create all of your SB objects here
--queues, contracts, message types, services, activation
......@@ -431,8 +394,9 @@ BEGIN
JOIN sys.databases t5 ON t5.database_id = DB_ID()
WHERE t2.is_ms_shipped = 0 --dont show me system stuff
SELECT 'Contents of Q:WLWklstQueueTicklerQ' AS 'Q Contents', * FROM WLWklstQueueTicklerQ WITH (NOLOCK)
SELECT 'Contents of Q:WLWklstIBUQ' AS 'Q Contents', *, CONVERT(xml,message_body) FROM WLWklstIBUQ WITH (NOLOCK)
--display the contents of your queues here
SELECT 'Contents of Q:xxx' AS 'Q Contents', * FROM xxx WITH (NOLOCK)
SELECT 'Contents of Q:xxx' AS 'Q Contents', *, CONVERT(xml,message_body) FROM xxx WITH (NOLOCK)
select
'PerfMon',
......@@ -480,8 +444,8 @@ BEGIN
DECLARE @service1 varchar(4000), @service2 varchar(4000)
SELECT @exec_str = 'ssbdiagnose -IGNORE 29997 -IGNORE 29964 -E -S ' + CONVERT(varchar(255),@@SERVERNAME) + ' -d ' + CONVERT(varchar(255),DB_NAME())
SELECT @exec_str = @exec_str + ' CONFIGURATION FROM SERVICE '
SELECT @service1 = @exec_str + 'WLWklstQueueTicklerSvc TO SERVICE WLWklstQueueTicklerSvc'
SELECT @service2 = @exec_str + 'WLWklstIBUSvc TO SERVICE WLWklstIBUSvc'
SELECT @service1 = @exec_str + 'xxx TO SERVICE xxx'
SELECT @service2 = @exec_str + 'xxx TO SERVICE xxx'
SELECT @service1
EXEC master..xp_cmdshell @service1
SELECT @service2
......@@ -499,67 +463,7 @@ BEGIN
------------------------------------------------------------------------------------------------------------------------------------------------------
PRINT 'Beginning End-to-End testing. These are not totally conclusive tests, but are a good indicator things are working.'
DECLARE @Test TABLE (ObjId BIGINT);
INSERT INTO @Test
SELECT TOP 1 bpbp.ObjId
FROM dbo.BlPerBlPty bpbp
JOIN dbo.WLWklstObjInsBlUnit i
ON bpbp.ObjId = bpbp.ObjId;
--first set a value in the flattened table such that an update will occur
UPDATE dbo.WLWklstObjInsBlUnit SET CntcObjId = -999 WHERE ObjId IN (select ObjId FROM @Test);
--now simulate an update from the application
PRINT 'Simulating an update to a BPBP'
UPDATE dbo.BlPerBlPty SET LastCngDTime = LastCngDTime WHERE ObjId IN (select ObjId FROM @Test)
IF NOT EXISTS (
SELECT *
FROM WLWklstQueue q (NOLOCK)
JOIN WLWklstQueueType t
ON q.WLWklstQueueTypeObjId = t.ObjId
JOIN @Test tst
ON q.ObjId = tst.ObjId
WHERE t.ObjIdType = 'BlPerBlPty'
)
BEGIN
RAISERROR ('WARNING: Row either never made it to WLWklstQueue or was dequeued faster than we could retrieve it.',10,1)
END;
ELSE
BEGIN
PRINT 'Row was updated and successfully sent to WLWklstQueue'
END;
WAITFOR DELAY '00:00:06'
--Check that row is not in trigger q
IF EXISTS (
SELECT *
FROM WLWklstQueue q (NOLOCK)
JOIN WLWklstQueueType t
ON q.WLWklstQueueTypeObjId = t.ObjId
JOIN @Test tst
ON q.ObjId = tst.ObjId
WHERE t.ObjIdType = 'BlPerBlPty'
)
BEGIN
RAISERROR ('WARNING: Row appears stuck in WLWklstQueue.',10,1)
END
DECLARE @testtimer INT
WHILE EXISTS (SELECT * FROM WLWklstObjInsBlUnit WHERE ObjId IN (select ObjId FROM @Test) AND CntcObjId = -999)
BEGIN
SELECT @testtimer = @testtimer + 1
PRINT 'Flattened data is still out-of-sync, waiting 2 secs'
WAITFOR DELAY '00:00:02'
IF @testtimer = 10
BEGIN
RAISERROR ('WARNING: Row appears to be stuck in flattening Q.',10,1);
END;
END;
PRINT 'Check for WARNING messages above.'
......@@ -577,7 +481,7 @@ BEGIN
SELECT conversation_handle
FROM sys.conversation_endpoints
WHERE state_desc <> 'CLOSED'
AND far_service <> 'WLWklstQueueTicklerSvc'
AND far_service <> 'xxx'
open cur
fetch next from cur into @conv
while @@fetch_status = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment