收到消息时未检索到 msmq AppSpecific
msmq AppSpecific was not retrieved when receiving the message
我想使用 MSMQ 传输消息。当我发送消息时,我将一个枚举 (StudentMessageType) 作为 AppSpecific 传递,这样我就可以识别我应该在目的地做什么。但是当我尝试接收消息时,我无法访问 AppSpecific 属性 并且出现此异常:
Property AppSpecific was not retrieved when receiving the message.
Ensure that the PropertyFilter is set correctly.
我应该怎么做才能收到 AppSpecific?
发送
var requestQueue = new MessageQueue(@".\private$\req");
requestQueue.MessageReadPropertyFilter.AppSpecific = true;
requestQueue.Formatter = new BinaryMessageFormatter();
Message studentNameMessage = new Message(studentName, new BinaryMessageFormatter());
studentNameMessage.AppSpecific = (int) Student.StudentMessageType.AddStudent;
requestQueue.Send(studentNameMessage, MessageQueueTransactionType.Single);
requestQueue.Close();
收到
requestQueue = new MessageQueue(@".\private$\req");
requestQueue.Formatter = new BinaryMessageFormatter();
MessageQueueTransaction transaction = new MessageQueueTransaction();
try
{
transaction.Begin();
Message message = requestQueue.Receive(transaction);
output = (string)message.Body;
output += "\t" + ((Student.StudentMessageType) message.AppSpecific).ToString();
transaction.Commit();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
天哪,我只是忘记了接收方法中的这一行:
requestQueue.MessageReadPropertyFilter.AppSpecific = true;
我想使用 MSMQ 传输消息。当我发送消息时,我将一个枚举 (StudentMessageType) 作为 AppSpecific 传递,这样我就可以识别我应该在目的地做什么。但是当我尝试接收消息时,我无法访问 AppSpecific 属性 并且出现此异常:
Property AppSpecific was not retrieved when receiving the message. Ensure that the PropertyFilter is set correctly.
我应该怎么做才能收到 AppSpecific?
发送
var requestQueue = new MessageQueue(@".\private$\req");
requestQueue.MessageReadPropertyFilter.AppSpecific = true;
requestQueue.Formatter = new BinaryMessageFormatter();
Message studentNameMessage = new Message(studentName, new BinaryMessageFormatter());
studentNameMessage.AppSpecific = (int) Student.StudentMessageType.AddStudent;
requestQueue.Send(studentNameMessage, MessageQueueTransactionType.Single);
requestQueue.Close();
收到
requestQueue = new MessageQueue(@".\private$\req");
requestQueue.Formatter = new BinaryMessageFormatter();
MessageQueueTransaction transaction = new MessageQueueTransaction();
try
{
transaction.Begin();
Message message = requestQueue.Receive(transaction);
output = (string)message.Body;
output += "\t" + ((Student.StudentMessageType) message.AppSpecific).ToString();
transaction.Commit();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
天哪,我只是忘记了接收方法中的这一行:
requestQueue.MessageReadPropertyFilter.AppSpecific = true;