none
WCF channel fault handling & Abandon a faulted message RRS feed

  • Question

  • Hi,

    I have a problem when trying to Abandon a message whenever fault happens. The code snippet and error message are as below:

    Code snippet

    if (!ReceiveContext.TryGet(OperationContext.Current.IncomingMessageProperties, out receiveContext))

    {

    Console.WriteLine("ReceiveContext not installed/found on this machine.");

           return;

    }

    receiveContext.Faulted += new EventHandler(ReceiveContextFaulted);

    void ReceiveContextFaulted(object sender, EventArgs e)

    {

    try

           {

           Log.Error("Receive Context Faulted.");

                  receiveContext.Abandon(TimeSpan.FromSeconds(msgTimeout));

           }

           catch (Exception)

           {

                 

           }

    }   

    ERROR Message   

    callback threw an exception. Check the exception stack and inner exception to determine the callback that failed., Inner exception The receive context, Microsoft.ServiceBus.Messaging.Channels.ServiceBusInputChannelBase`1+AfmsReceiveContext[System.ServiceModel.Channels.IInputChannel], cannot be used for sending delayed acks because it is in the Faulted state.

    Question

    1. Whenever fault happens,      how to Abandon a message?
    2. What is the best mechanism      to handle this scenario?

    Thank you!

    Kalai

    Wednesday, May 6, 2015 12:46 PM

All replies