ID BIGINT PRIMARY IDENTITY, SoapEndpoint NVARCHAR(256), Escalation INT, Other Metadata
ID UNIQUEIDENTIFIER PRIMARY, Payload VARBINARY(MAX), Other Metadata
SubscriberID UNIQUEIDENTIFIER PRIMARY, MessageID UNIQUEIDENTIFIER PRIMARY, Retries INT = 0, IsDelivered BIT = 0,
- Add subscriber to Subscriber table.
- Remove subscriber from Subscriber table.
VB.Net:
- Create GUID (=
mid
) SQL: - Insert message into Message table (ID =
mid
) - Foreach Subscriber (
sid
=ID), insert into MessageDelivery table (SubscriberID =sid
, MessageID =mid
) - SELECT MD.SubscriberID, MD.MessageID, MD.Retries, M.Payload, S.SoapEndpoint, S.Escalation From MessageDelivery AS MD JOIN Message AS M ON MD.MessageID = M.ID JOIN Subscriber AS S ON MD.SubscriberID = S.ID WHERE MD.MessageID = @mid AND MD.SubscriberID = @sid AND M.IsDelivered = 0;
VB.Net:
- PAUSE (not stop/reset) redeliver tick timer
- For each row from BeforeDeliver -- Call SOAP endpoint with message payload (this will probably be 'anonymous' XML - i.e. WebService with XmlDocument as the only parameter). -- If it fails increase Retries, otherwise set IsDelivered to 1. -- Check to see if Retries matches Escalation, if it does notify admin.
- Resume deliver tick timer
SELECT MD.SubscriberID, MD.MessageID, MD.Retries, M.Payload, S.SoapEndpoint, S.Escalation From MessageDelivery AS MD JOIN Message AS M ON MD.MessageID = M.ID JOIN Subscriber AS S ON MD.SubscriberID = S.ID WHERE M.IsDelivered = 0 AND M.Retries < S.Escalation VB.Net:
- For each row returned -- Call SOAP endpoint with message payload (this will probably be 'anonymous' XML - i.e. WebService with XmlDocument as the only parameter). -- If it fails increase Retries, otherwise set IsDelivered to 1. -- Check to see if Retries matches Escalation, if it does notify admin.