• OK, as to your specific design question here is how I would do it:

    A) Add a table like this:

    CREATE TABLE PreProcessingLog

    (

    CustomerIDint,

    CompletionTypeint,

    --Types are 1=UserRequest, 2=DocType1, 4=DocType2, 8=DocType3

    Primary Key Clustered (CustomerID, CompletionType)

    )

    B) When the User request is issued or at the completion of each Document Type's pre-processing, INSERT the appropriate record into this table, then send the corresponding message to your service broker service.

    C) The queue activation procedure should do the following:

    -- 1. Begin a transaction

    -- 2. Read the message from the queue

    -- 3. Execute the following check:

    IF (

    SELECT SUM(CompletionType)

    FROM PreProcessingLog

    WHERE CustomerID = @RecvdCustID

    ) 15

    BEGIN

    COMMIT TRANSACTION

    RETURN 0

    END

    -- 4. Otherwise, continue to do the post-processing

    -- 5. Delete all of the CustomerID=@RecvdCustID rows from PreProcessingLog

    -- 6. Commit the transaction & return.

    Now you can also throttle the intensity of the post-processing by limiting the number of concurrent queue activations.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]