0
SQL Broker Queueのアクティベーションストアドプロシージャにログを追加することを決めました。目標はエラーを記録することです。テスト時には、ログテーブルにエラーが連続して記録されます。 LOGGINGを追加する前にSQL BrokerアクティベーションProcのログ記録過度に
:
- すべてがないシステムまたはイベントログ
- 偉大な作品は、問題
- Serverのパフォーマンスは、かろうじて 'ブリップ' AFTER
を示して示してログを追加:
Th電子サーバーのパフォーマンスは、まだかろうじて「ブリップ」を示しているが、...
- ログテーブルには、継続的にサービスキュー「OutboundEventRequestQueueは」現在無効になっている、次のエラーで
を満たしています。
私は、次のコマンドを実行するまでロギングは停止しません
のALTER DATABASE [MyDatabaseName] ROLLBACK IMMEDIATE
ストアドプロシージャWITH SETのNEW_BROKER:
ALTER PROCEDURE [dbo].[usp_OutboundEventRequestQueueActivation]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ConversationHandle UNIQUEIDENTIFIER;
DECLARE @MessageBody XML;
DECLARE @MessageTypeName SYSNAME;
---------------
-- READS ALL THE MESSAGES IN THE QUEUE
---------------
WHILE (1=1)
BEGIN
BEGIN TRY
BEGIN TRANSACTION;
---------------
-- KEEPS READING While In 'Notified' State
---------------
WAITFOR
(
RECEIVE TOP (1)
@ConversationHandle = conversation_handle,
@MessageBody = CAST(message_body AS XML),
@MessageTypeName = message_type_name
FROM [dbo].[OutboundEventRequestQueue]
), TIMEOUT 5000;
IF (@@ROWCOUNT = 0)
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END
---------------
-- HANDLE REPLY MESSAGE: OutboundEventRequest
---------------
IF @MessageTypeName = N'OutboundEventRequestMessageType'
BEGIN
-- DEBUG ONLY: Use to force an error
--WAITFOR DELAY '00:00:01'
--------------
-- INSERT AUDIT
--------------
DECLARE @AuditedEvent XML;
EXEC [event].[usp_tOutbound_Audit_UPSERT] @MessageBody, @AuditedEvent = @AuditedEvent OUTPUT
---------------
-- DO WORK
---------------
-- Publish XML Message (payload) to Outbound Event Aggregator (using SQL CLR)
DECLARE @Payload NVARCHAR(MAX) = (SELECT CONVERT(NVARCHAR(MAX), @AuditedEvent))
EXEC dbo.usp_OutboundEventMessage_PUBLISH @outboundEvent = @Payload
-- SEND REPLY
DECLARE @ReplyMessageBody XML = @MessageBody;
SEND ON CONVERSATION @ConversationHandle MESSAGE TYPE [OutboundEventResponseMessageType] (@ReplyMessageBody);
END
---------------
-- HANDLE ERRORS: for EndDialog MessageTypes
---------------
ELSE IF @MessageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
-- CLOSE CONVERSATION
END CONVERSATION @ConversationHandle;
END
---------------
-- HANDLE ERRORS: for Error MessageTypes
---------------
ELSE IF @MessageTypeName = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
BEGIN
-- CLOSE CONVERSATION
END CONVERSATION @ConversationHandle;
END
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION;
DECLARE @Error_Number INT = (SELECT ERROR_NUMBER())
DECLARE @Error_Message VARCHAR(MAX) = (SELECT ERROR_MESSAGE())
DECLARE @Error_Severity INT = (SELECT ERROR_SEVERITY())
DECLARE @Error_State INT = (SELECT ERROR_STATE())
DECLARE @Error_Procedure VARCHAR(400) = (SELECT ERROR_PROCEDURE())
DECLARE @Error_Line INT = (SELECT ERROR_LINE())
-- HERE: The log-table is continuously FILLING-UP
EXEC [event].[usp_Exceptions_TRYINSERT]
@Error_Number,
@Error_Message,
@Error_Severity,
@Error_State,
@Error_Procedure,
@Error_Line
END CATCH
END
END
QUEUE:
ALTER QUEUE [dbo].[OutboundEventRequestQueue] WITH STATUS = OFF , RETENTION = OFF , ACTIVATION ( STATUS = ON , PROCEDURE_NAME = [dbo].[usp_OutboundEventRequestQueueActivation] , MAX_QUEUE_READERS = 10 , EXECUTE AS OWNER ), POISON_MESSAGE_HANDLING (STATUS = ON)