Ending a conversation in a CLR activated stored procedure

I've read Remus' article on Fire and Forget tactics when it comes to ending conversations, and I have to admit I am guilty of sending a message to a service and immediately ending the conversation. I've set up a stored procedure to end the conversation on the initiator queue, but I'm guessing it's never being fired because I am not ending the conversation in the target activated stored proc, which is a CLR stored proc.

Can you tell me how to end the conversation from a CLR stored proc

Now that I think of it none of the code I use in my TSQL activated stored procs to handle different message types and error-checking is done in the CLR stored proc.

Thanks



Answer this question

Ending a conversation in a CLR activated stored procedure

  • Torsten_F

    Thanks Remus. That's what I figured. I was using the ServiceBrokerInterface to interface with SSB, and I realized I just needed to end the conversation after I received the message from the service I created. Thanks again.
  • kmcdermott

    That's what I ended up doing. Thanks Rushi.
  • wcpc_el

    An activated CLR procedure should basically do everything a T-SQL proc does. That is, must be prepared to deal with EndDialog and Error message types, must end dialogs appropiately when the case etc.

    To end a conversation from CLR, you must execute the END CONVERSATION statement using a SqlCommand.ExecuteNonQuery.

    HTH,
    ~ Remus



  • Edcase_70

    The Conversation class has an End() method which you can call. Conversation is a property of the Message class. So if you are implementing the callbacks as methods annotated with the [BrokerMethod] attribute, simply do the following

    [BrokerMethod(...)]
    public void OnXXXMessage(Message msgReceived, SqlConnection...)
    {
    // process the message
    msgReceived.Conversation.End();
    }


  • Ending a conversation in a CLR activated stored procedure