From: http://ysqraymond.spaces.live.com/blog/cns! 837000054153d06d9! 222. Entry
I recently studied. Net Pet Shop 4 when nothing happened. Although it has been released for a long time, I didn't have time to read it.
After reading the architecture, model, profile mechanism, and a set of login templates, I think Microsoft is really Program Considerate and considerate. However, when I want to run Asynchronous Message Processing for. Net Pet Shop 4, there is always an error. After inspection, the following changes need to be made:
1: Modify the web as readme in pet shop 4. <add key = "orderstrategyclass" value = "petshop. bll. ordersynchronous "/> is <add key =" orderstrategyclass "value =" petshop. bll. orderasynchronous "/> 2: Modify <add key =" orderqueuepath "value =" formatname: Direct = OS: machinname \ private $ \ psorders "/> is <add key =" orderqueuepath "value =" formatname: Direct = OS :. \ private $ \ psorders "/>, here. indicates the local machine. Note that you can also use the machine name. This format should be specified by Active Directory. The write efficiency is also higher. 3: Modify the app under the orderprocessor folder. config File, <add key = "orderqueuepath" value = "formatname: Direct = OS: change machinename \ private $ \ psorders "/> to <add key =" orderqueuepath "value =" formatname: Direct = OS :. \ private $ \ psorders "/> 4: Create transactional queue on the local machine, choose Control Panel> Administrative Tools> Computer Management> services and Application> Message Queuing> privary queues> right-click on the right and choose new> privary queue> enter psorders, and do not forget to select The checkbox of transactional in the lower part, because the message in. Net pet shop uses a transactional message, which will be explained later. If you cannot see the Message Queuing, your message service may not be enabled, enter services. msc, and then enable the message service and DCOM Service. Now you can probably test your program. First, you need to log on, submit, and run the orderprocessor console program. Then you can see that the item is processed. Second, I think some machines will regard \ as escape, but some will not (otherwise, isn't it a joke for Microsoft to write it like this ?), Therefore, use it with caution. If an error occurs in the original method, consider this. The fourth one must be noted. Select the following checkbox. To put it simply, MSMQ. To Implement Asynchronous information processing, MSMQ is one of the options and seems to be a pretty good choice. As for the reason, I will not elaborate here. 1: first look at the Message Queue path problem:
. \ Devxtestqueue |
References a public queue namedDevxtestqueueOn the local machine. |
Server01 \ devxtestqueue |
References a public queue namedDevxtestqueueOn a machine namedServer01(Local queues can be referenced with a machine name as well ). |
. \ Private $ \ devxtestqueue |
References a private queue namedDevxtestqueueOn the local machine. |
Server01 \ private $ \ devxtestqueue |
References a private queue namedDevxtestqueueOn a machine namedServer01. |
Direct format names |
Formatname: Direct = OS:. \ devxtestqueue |
References a public queue namedDevxtestqueueOn the local machine. |
Formatname: Direct = OS: server01 \ devxtestqueue |
References a public queue namedDevxtestqueueOn a machine namedServer01. |
Formatname: Direct = TCP: 127.0.0.1 \ private $ \ devxtestqueue |
References a private queue namedDevxtestqueueOn the local machine. |
2: The message formats include activexmessageformatter, binarymessageformatter, and xmlmessageformatter. For common text messages, you can use xmlmessageformatter. Of course, there are many useful resources and bandwidth. If the message needs to be sent to an object, you can use binarymessageformatter, which is fast, however, activemessageformatter is mostly used to send component objects to implement the object's serial Hua and deserialization. 3: messages also have some good attributes, such Correlationid can ensure that after the client sends a message to the server for processing and takes effect of the response, the client can accurately know which message corresponds to which message, which is determined by correlationid, because the client contains this ID when sending a message, the server always attaches this ID when processing the message, and still sends the ID back when sending the response, so that the client can recognize it. The client can also create a reponsequeue so that the server's response is naturally sent to the created reponsequeue on the client, which is also very convenient. 4: transactional messages: the reason why a message is transactional is that the first is for fear of message loss, and the second is for fear that the message is not processed in the order in which it is sent with a consistent result error. To avoid these deficiencies, we use transactional messages. You can select single, atomatic, and none when using them. Generally, if another transaction is encountered during message processing, for example, for database transactions, you should select atomatic. If security requirements are not high, you can use none. If only one operation is performed on the queue in one transaction, such as inserting message, to delete a message, you can use single. For more information, see msdn.ArticleGood: http://www.codeproject.com/dotnet/msmqpart2.asp 5 :. net 20.0 provides a lot of good support for messages. Users only need to use a few simple functions, so they no longer understand all the message loops like the previous MFC, the painful times will not return. If MSMQ is used. add system. message. DLL reference is acceptable. The above is a record of MSMQ.