USP_BBWORKFLOW_SERVICE_ADD_QUEUEMESSAGE_ERROR

Used by the workflow service to log an error while attempting to deliver a workflow service queue message.

Parameters

Parameter Parameter Type Mode Description
@MESSAGEBODY nvarchar(max) IN
@MESSAGETYPE nvarchar(128) IN
@CONVERSATION_GROUP_ID uniqueidentifier IN
@ERRORMESSAGE nvarchar(max) IN
@ERRORDETAILS nvarchar(max) IN
@ERRODATE datetimeoffset IN
@ORIGINAL_CONVERSATION_HANDLE uniqueidentifier IN
@BBWORKFLOWINSTANCEINFOID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN
@ID uniqueidentifier INOUT

Definition

Copy


create procedure dbo.USP_BBWORKFLOW_SERVICE_ADD_QUEUEMESSAGE_ERROR

/*
Used by the workflow service to log an error while attempting to deliver a workflow service queue message.
*/

@MESSAGEBODY nvarchar(max),
@MESSAGETYPE nvarchar(128),
@CONVERSATION_GROUP_ID uniqueidentifier,
@ERRORMESSAGE nvarchar(max),
@ERRORDETAILS nvarchar(max),
@ERRODATE datetimeoffset(7),
@ORIGINAL_CONVERSATION_HANDLE uniqueidentifier,
@BBWORKFLOWINSTANCEINFOID uniqueidentifier = null,
@CHANGEAGENTID uniqueidentifier = null,
@ID    uniqueidentifier = null output

as


set nocount on;

if @CHANGEAGENTID is null 
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

declare @date datetime;
set @date = getDate();

if @ID is null set @ID = NewID();

if @BBWORKFLOWINSTANCEINFOID = '00000000-0000-0000-0000-000000000000' SET @BBWORKFLOWINSTANCEINFOID = NULL;

declare @VALID_INSTANCE_RECORDID_ORNULL uniqueidentifier;

--If there is a workflow instance for this error group associate error and log with the instance, otherwise just an entry with no instance.

select @VALID_INSTANCE_RECORDID_ORNULL = ID FROM dbo.BBWORKFLOWINSTANCEINFO WHERE ID=@BBWORKFLOWINSTANCEINFOID;


insert into dbo.BBWORKFLOW_QUEUEMESSAGE_ERROR
(ID,MESSAGEBODY,MESSAGETYPE,[CONVERSATION_GROUP_ID],ERRORMESSAGE,ERRORDETAILS,ERRORDATE,ORIGINAL_CONVERSATION_HANDLE,DATEADDED,DATECHANGED,ADDEDBYID,CHANGEDBYID,BBWORKFLOWINSTANCEINFOID)

values(@ID,
@MESSAGEBODY ,
@MESSAGETYPE ,
@CONVERSATION_GROUP_ID ,
@ERRORMESSAGE ,
@ERRORDETAILS,
@ERRODATE ,
@ORIGINAL_CONVERSATION_HANDLE,
@date,
@date,
@CHANGEAGENTID,
@CHANGEAGENTID,
@VALID_INSTANCE_RECORDID_ORNULL
);


/* 

Also add a row to the workflow log.

*/

declare    @LOGID uniqueidentifier=newid();


declare @addLogResult int;


begin try


    declare @LOGTYPECODE tinyint = 2; --error.

    declare @SOURCECODE tinyint = 4; --workflow queue


    declare @LOGMESSAGE nvarchar(max);

    set @LOGMESSAGE='Workflow Queue delivery error: ' + @ERRORMESSAGE;

    exec @addLogResult = dbo.USP_BBWORKFLOW_ADD_LOG_MESSAGE @LOGID,@CHANGEAGENTID,@VALID_INSTANCE_RECORDID_ORNULL,@LOGTYPECODE,@LOGMESSAGE, @SOURCECODE;


end try

begin catch
    -- eat an error logging the result so that the message will still be picked off of the queue to avoid a poison message.    

    exec dbo.USP_RAISE_ERROR;
    return 100;
end catch