人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

August 19, 2006

PetShop的Order和Message Queuing

Filed under: 代码学习

MSMQ与XML Web Services和.Net Remoting一样,是一种分布式开发技术。但是在使用XML Web Services或
.Net Remoting组件时,Client端需要和Server端实时交换信息,Server需要保持联机。
MSMQ以异步的方式和Server端交互,不用担心等待Server端的长时间处理过程。
在Server离线的情况下工作,将Message临时保存在Client端的消息队列中,以后联机时再发送到Server端处理。

在.Net环境下编写简单的Message Queue程序

安装Message Queuing Services
Control Panel->Add/Remove Programs->Add/Remove Windows Components安装MSMQ。

PetShop中的MesageQueuing

1. Factory class, create order Messaging implementation specified from the configuration file.

PetShop.MessagingFactory.QueueAccess
{
private static readonly string path = ConfigurationManager.AppSettings[”OrderMessaging”];

private QueueAccess() { }

public static PetShop.IMessaging.IOrder CreateOrder()
{
string className = path + “.Order”;
return (PetShop.IMessaging.IOrder)Assembly.Load(path).CreateInstance(className);
}
}

2. PetShop.IMessaging.IOrder

public interface IOrder
{
OrderInfo Receive();

OrderInfo Receive(int timeout);

void Send(OrderInfo orderMessage);
}

3. 通过transactional queue收发message的类的base class.
public class PetShopQueue : IDisposable
{

}

4. 具体类,通过MSMQ收发订单
PetShop.MSMQMessaging.Order: PetShopQueue, PetShop.IMessaging.IOrder
{

}

参考:
监视消息队列
http://www.netscum.dk/technet/prodtechnol/windowsserver2003/zh-CHS/library/RMS/RMSoperationsTC/a7109399-3a84-4681-874b-f6ea1646b0a0.mspx?mfr=true
.Net快速入门
http://chs.gotdotnet.com/quickstart/howto/doc/sendobject.aspx

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/08/19/p156/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham