对MSMQ 的一个简单封装 搏客 Winning 2006-07-03 11:27
using System;
using System.IO;
using System.Messaging;
using Util;
namespace MQ
{
public class MSMQ
{
private Type m_type = null;
private string m_queuepath = null;
public MSMQ(string QueuePath)
{
this.m_queuepath = QueuePath;
if (!MessageQueue.Exists(this.m_queuepath)) MessageQueue.Create(this.m_queuepath);
}
public void Send(object obj)
{
try
{
MessageQueue mq = new MessageQueue(m_queuepath);
mq.Send(new Message(obj));
if (m_type == null) m_type = obj.GetType();
}
catch (Exception exc)
{
LogWriter.WriteLog("MSMQ.Send", exc.Message);
}
}
public object Receive(Type type)
{
MessageQueue mq = new MessageQueue(m_queuepath);
mq.Formatter = new XmlMessageFormatter(new Type[] { type });
try
{
Message msg = mq.Receive();
return msg.Body;
}
catch (Exception exc)
{
LogWriter.WriteLog("MSMQ.Receive", exc.Message);
return null;
}
}
public object Receive()
{
return Receive(this.m_type);
}
}
}
re: 解UrlPathEncode的字符串的噩梦 搏客 Winning 2005-05-10 09:27
我们做项目的时候几乎不用Querystring传输中文
工厂模式的一个应用---统一数据库差异 搏客 Winning 2005-04-29 10:52
re: [ASP.net]未解的疑惑! 搏客 Winning 2005-04-12 09:50
当然是Open()和Close()一次来得要快,但是方法的细粒度带来的
灵活性和性能是矛盾的。这需要权衡一下。
不错,以前看过国外一个小公司做的类似产品。好象要$90