Also, consider putting this all in a TRY CATCH block.
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
..
message news:OE44WpCdHHA.3960@TK2MSFTNGP04.phx.gbl...
some table and commit). If the mail fails over and over again, you will
"Roger Wolter[MSFT]" <rwolter@online.microsoft.com> wrote in message
news:O17ToOBdHHA.4468@TK2MSFTNGP03.phx.gbl...
> I'm not sure I understand your activation proc - it looks like you're
> beginning the dialog sending
> and receiving in the same proc? I'm not sure how that work - where do the
> messages come from that
> activate the procedure?
>
> Anyway, for the receive part put a BEGIN TRANSACTION before the RECEIVE,
> and if the mail is sent
> correctly do the END CONVERSATION and COMMIT. If there is an error in the
> mail sending, do a
> ROLLBACK.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of included script samples are subject to the terms specified at
>
http://www.microsoft.com/info/cpyright.htm >
> "scott ocamb" <socamb@kiinc.com> wrote in message
> news:u8gNMEAdHHA.3648@TK2MSFTNGP05.phx.gbl...
>> thanks for your response.
>>
>> Any help would be appreciated....
>>
>>
>> I do this to set the activation proc.
>>
>> ALTER QUEUE [KS_EmailRecieveQueue] WITH ACTIVATION
>> ( STATUS = ON, MAX_QUEUE_READERS = 1,
>> PROCEDURE_NAME = KS_Recieve_EmailMessage_FromQueue, EXECUTE AS OWNER)
>>
>>
>> here is the activation proc.
>>
>> DECLARE @conversation_handle UNIQUEIDENTIFIER,
>> @message_body XML,
>> @message_type_name NVARCHAR(128);
>> DECLARE @msg NVARCHAR(128)
>> BEGIN DIALOG CONVERSATION @conversation_handle
>> FROM SERVICE KS_EmailSendService
>> TO SERVICE 'KS_EmailRecieveService'
>> ON CONTRACT KS_EmailContract
>> WITH ENCRYPTION=OFF;
>>
>>
>> -- Tran in here somewhere?????
>>
>>
>> RECEIVE TOP(1)
>> @conversation_handle = conversation_handle,
>> @message_type_name = message_type_name,
>> @message_body = message_body
>> FROM [dbo].[KS_EmailRecieveQueue]
>>
>> IF @message_type_name = 'KS_EmailMessage'
>> BEGIN
>> SELECT @message_body AS MESSAGE
>> SET @msg = CONVERT(nvarchar(Max), @message_body)
>> select @MSG
>>
>> -- THIS IS A C# METHOD
>>
>> exec KS_BULKMAIL_SP @msg
>>
>> END
>> END CONVERSATION @conversation_handle WITH CLEANUP ;
>>
>>
>> Thanks for your help!!!!!
>>
>>
>> "Roger Wolter[MSFT]" <rwolter@online.microsoft.com> wrote in message
>> news:e4AiZf$cHHA.4632@TK2MSFTNGP03.phx.gbl...
>>> Do a BEGIN TRANSACTION before doing the receive and then don't commit
>>> the transaction until the
>>> mail is sent successfully. A RECEIVE command is actually a delete so if
>>> the transaction commits
>>> the message is gone. That's the way error handling works in all
>>> transactional messaging.
>>>
>>> --
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> Use of included script samples are subject to the terms specified at
>>>
http://www.microsoft.com/info/cpyright.htm >>>
>>> "scott ocamb" <socamb@kiinc.com> wrote in message
>>> news:%23z0ksQ%23cHHA.2088@TK2MSFTNGP05.phx.gbl...
>>>>I am building a service broker implementation.
>>>> Our website allows a user to select a bunch of emails to send. These
>>>> emails are send to a
>>>> service broker queue.
>>>>
>>>> The receive queue executes an extended stored procedure written in C#.
>>>> This proc performs mail
>>>> merge work on the body and sends the email.
>>>>
>>>> I have noticed that when an error occurs, the item is no longer in the
>>>> service broker queue.
>>>> This is not good of course. I was expecting some sort of error or retry
>>>> queue like biztalk has.
>>>>
>>>> so..
>>>>
>>>> my question is how can i recover form errors and not loose items that
>>>> have been queued up.
>>>>
>>>> scott
>>>>
>>>
>>
>>
>