Course Order Application C# Help

To demonstrate the use of Message Queuing, in this section you create a sample solution to order courses. The sample solution is made up of three assemblies:

  1. A component library (Courseorder) that includes entity classes for the messages that are sent and received in the queue.
  2. A WPF application (CourseOrderSender) that sends messages to the message queue.
  3. A WPF application (CourseorderReceiver) that receives messages from the message queue

Course Order Class Library

Both the sending and the receiving application need the order information. For this reason, the entity classes are put into a separate assembly. The CourseOrder assembly includes three entity classes CourseOrder, Course, and Customer. WiUl the sample application, not all properties are implemented as they would be in a real application, but just enough properties to show the concept.

In the file Course. cs, the class Course is defined. This class has just one property for the title of the course:


The file Customer. cs includes the class Customer, which includes properties for the company and contact names:


The class CourseOrder in the file CourseOrder.cs maps a customer and a course inside an order and defines whether the order is high priority:


Course Order Message Sender

The second part of the solution is a Windows application called CourseOrderSender. With this application, course orders are sent to the message queue. The assemblies System. Messaging and CourseOrder must be referenced.

The user interface of this application is shown in Figure 45-10.The”items”o fthe combobox” comboBoxCourses include several courses such as Advanced Programming, Programming with LINQ, and Distributed Application Development using WCF.

When the Submit the Order button is clicked, the handler method buttonSubmit_Click() is invoked. With this method, a CourseOrder object is created and filled with the content from the Textbox and ComboBox controls. Then a MessageQueue instance is created to open a public queue with a format name. format name is used to send the message, even if the queue cannot be reached currently. You can get the format name by using the Computer Management snap-in to read the ID of the message queue. With the Send() method, the Course Order object is passed to serialize it with the default XmlMessAgeFormatter and to write it to the queue:


Figure 45-10

Figure 45-10

Posted on November 2, 2015 in Message Queuing

Share the Story

Back to Top