none
Malformed request message at high throughput RRS feed

  • Question

  • IOutboundHandler.Execute(Message message, TimeSpan timeout) appears to receive a message that is either malformed or in a 'Read' or 'Closed' state at high throughput. Consider this code:

    XmlDictionaryReader reader = message.GetReaderAtBodyContents();
    reader.ReadStartElement();
    string foo = reader.ReadElementContentAsString();

    At high throughput, messages will cause the following exceptions at ReadElemContentAsString():

    Microsoft.ServiceModel.Channels.Common.AdapterException: Error trying process operation: Start element expected. Found end element 'PublishText' from namespace 'jms://JNBridge.JMSAdapter'. ---> System.Xml.XmlException: Start element expected. Found end element 'PublishText' from namespace '*******'.
       at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
       at System.Xml.XmlExceptionHelper.ThrowStartElementExpected(XmlDictionaryReader reader)
       at System.Xml.XmlDictionaryReader.MoveToStartElement()
       at System.Xml.XmlBinaryReader.ReadElementContentAsString()

    or

    Microsoft.ServiceModel.Channels.Common.AdapterException: Error trying process operation: Unexpected end of file. Following elements are not closed: name, PublishText, Body, Envelope. ---> System.Xml.XmlException: Unexpected end of file. Following elements are not closed: name, PublishText, Body, Envelope.
       at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
       at System.Xml.XmlExceptionHelper.ThrowUnexpectedEndOfFile(XmlDictionaryReader reader)
       at System.Xml.XmlBufferReader.EnsureBytes(Int32 count)
       at System.Xml.XmlBufferReader.ReadBytes(Int32 count)
       at System.Xml.XmlBinaryReader.ReadName(StringHandle handle)
       at System.Xml.XmlBinaryReader.ReadNode()
       at System.Xml.XmlBinaryReader.ReadElementContentAsString()

    The LOB API is synchronous. The scenario: the adapter is consumed in Visual Studio using the Add Adapter Service Reference to generate synchronous operations. The code uses a thread pool to asychronously call the same operation providing concurrentcy. If it matters, the concurrent mechanism is a DispatcherQueue from Microsoft Robotics CCR. The thread pool size is 10. At a high throughtput rate, The request message appears to have already been processed. At lower throughput, the error never occurs.

    This is at a customer site so I don't have much information. I've sent them the necessary configuration snippet to trace messages. All WCF LOB settings are default.

    Thanks,

    Bill


    Bill Heinzman JNBridge, LLC www.jnbridge.com
    Wednesday, July 28, 2010 12:40 AM

Answers

  • This sounds like more of a thread problem where more than one thread is using the same message. Is the code using any synchronization mechanisms? Also, is there any static members and/or methods?

    Another approach for getting the content of an XLangMessage is to do this:

    public static string GetMsgAsString(XLANGMessage msg) {
    string strMsg = "";
    using (msg as IDisposable) {
      // Read the message
      StreamReader re = new StreamReader((Stream)msg[0].RetrieveAs(typeof(Stream)));
      strMsg = re.ReadToEnd();
      re.Close();
    }
    return strMsg;
    }

    Thanks,

     


    If this answers your question, please use the "Answer" button to say so | Ben Cline

     

     

     

    Wednesday, July 28, 2010 3:59 AM
    Moderator