Querying Data Asynchronously with Message Queuing

[ Team LiB ] Recipe Querying Data Asynchronously with Message Queuing Problem You want to asynchronously retrieve data from a system that is not always connected. Solution You must | Team LiB Recipe Querying Data Asynchronously with Message Queuing Problem You want to asynchronously retrieve data from a system that is not always connected. Solution You must Use message queuing to construct and send a data request from the client. Access and process the requesting message at the server. Compose and send a response message containing the result set to the client. Retrieve the response at the client and deserialize it into a DataSet. The sample code contains three event handlers Send Checks if the query message queue exists and creates it if necessary. A MessageQueue object is created to access the queue. A message is sent to the queue containing the CustomerlD which the user wants information about. Process Query Checks if the query message queue exists and creates it if necessary. A MessageQueue object is created to access the queue. An attempt is made to receive a message from the queue waiting one second before giving up. If a message is received the CustomerlD is extracted from the message and the message queue is closed. A DataSet is created and a DataAdapter is used to return the record for the requested CustomerID into a Customer DataTable in the DataSet. A result queue is created if necessary and a message labeled with the CustomerlD and containing the DataSet with the asynchronous query results is sent to the queue. Process Result Checks if the result message queue exists and creates it if necessary. A MessageQueue object is created to access the queue and the formatter set to deserialize the DataSet in the message bodies. An attempt is made to receive a message from the queue waiting for one second before giving up. If a message is received the DataSet in the body is deserialized and the contents are displayed. The C code is shown in Example 2-31. Example 2-31. File Namespaces variables and constants using System using using using .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
138    723    2    01-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.