Message Queue Error: cannot find a formatter capable of reading message

前端 未结 9 1965
耶瑟儿~
耶瑟儿~ 2020-12-15 16:24

I\'m writing messages to a Message Queue in C# as follows:

queue.Send(new Message(\"message\"));

I\'m trying to read the messages as follow

9条回答
  •  清歌不尽
    2020-12-15 17:09

    This worked for me to read a private queue from a remote machine:

    MessageQueue queue = new MessageQueue(@"FormatName:Direct=OS:MACHINENAME\private$\MyQueueName", QueueAccessMode.Peek);
    
    Message msg = queue.Peek();
    StreamReader sr = new StreamReader(msg.BodyStream);
    string messageBody = sr.ReadToEnd();
    

    Update 2019-11-29

    Don't use Microsoft Message Queue (MSMQ). Just don't. It is both deprecated, and bottom of the pile in terms of anything useful, performant or even remotely well designed.

提交回复
热议问题