What should you do?

A Windows-based application receives messages from a message queue named PriorityQueue.
The client application sets the Priority property on the message before sending it.
However, received Message objects do not have the Priority property assigned.
The following code is used to receive the messages.

(Line numbers are included for reference only.)
01 MessageQueue queue = new MessageQueue(“.\\PriorityQueue”);
02 Message m = queue.Receive();
03 Console.WriteLine(m.Priority);

You need to ensure that the Windows-based application that receives the messages can access the Priority property.

What should you do?

A Windows-based application receives messages from a message queue named PriorityQueue.
The client application sets the Priority property on the message before sending it.
However, received Message objects do not have the Priority property assigned.
The following code is used to receive the messages.

(Line numbers are included for reference only.)
01 MessageQueue queue = new MessageQueue(“.\\PriorityQueue”);
02 Message m = queue.Receive();
03 Console.WriteLine(m.Priority);

You need to ensure that the Windows-based application that receives the messages can access the Priority property.

What should you do?

A.
Replace line 01 with the following code segment.
MessageQueue queue = new MessageQueue(“.\\PriorityQueue”, QueueAccessMode.ReceiveAndAdmin);

B.
Insert the following line of code between lines 01 and 02.
queue.MessageReadPropertyFilter.Priority = true;

C.
Insert the following code segment between lines 01 and 02.
queue.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) });

D.
Insert the following code segment between lines 01 and 02.
DefaultPropertiesToSend s = new DefaultPropertiesToSend();
s.Priority = MessagePriority.High;
queue.DefaultPropertiesToSend = s;



Leave a Reply 0

Your email address will not be published. Required fields are marked *