Share data through MSMQ
来源:互联网 发布:淘宝虚拟店铺入驻 编辑:程序博客网 时间:2024/04/29 06:53
firstly. you have to install MSMQ in your computer. Open your add/remove component in your control panel. Select Application Server/Message Queuing, then click OK to finish installing.
In Computer panel you can find Message Queuing node. It demostrates that you have successfully installed the MSMQ. Now let's create a MSMQ for our demo. Right click the Private Queues and select new-->private Queue and named it as MyQueue.
secondly, Create two Windows application for the demo. It will realize the Sender and Receiver of the MSMQ.
In the Sender application, you will add a MessageQueue component to the project. It named messageQueue1. Configure it property as follows. The most important two property.
one is Path = ./private$/MyQueue (. represents the local machine)
the other is Formatter = BinaryMessageFormatter (serilized Formatter)
Another application need the same configure, thus they point to the same MSMQ.
thirdly, write some code about send and receiver.
Sender Application:
private void Sender_Click(object sender, EventArgs e)
{
System.Collections.ArrayList al = new System.Collections.ArrayList();
al.Add("Henry");
al.Add("Tom");
al.Add("Jenny");
this.messageQueue1.Send(al, "My first MSMQ");
}
Receiver Application:
private void Receiver_Click(object sender, EventArgs e)
{
messageQueue1.BeginReceive();
}
private void messageQueue1_ReceiveCompleted(object sender, System.Messaging.ReceiveCompletedEventArgs e)
{
System.Messaging.Message msg = null;
msg = messageQueue1.EndReceive(e.AsyncResult);
System.Collections.ArrayList al = (System.Collections.ArrayList)msg.Body;
string str = "";
for (int i = 0; i < al.Count; i++)
{
str += al[i].ToString() + "/n";
}
MessageBox.Show(str);
}
ok, you can test it. enjoy MSMQ. very easy.
- Share data through MSMQ
- android-share simple data
- Conquer Big Data through Spark
- MSMQ
- MSMQ
- MSMQ
- MSMQ
- MSMQ
- MSMQ
- MSMQ
- MSMQ
- How to Share Data between testcase
- share data between build-in and module
- ClientDataSet get data through Application Server
- Apache Drill Could Power Faster Through Data
- Network Data Flow through the Linux Kernel
- Efficient data transfer through zero copy
- what vehicle data can play through OBD
- WINX新增(1): KMP字符串查找算法
- 董卿摔倒受伤 引明星舞台尴尬时刻盘点
- 中国电影六位最敢裸露的女人
- 一则佛教故事
- 《WEB应用测试》笔记(八)
- Share data through MSMQ
- 高分红不等于高收益
- Pub生涯
- 关于重构
- 大学的信
- 基金转换——乾坤大挪移
- Oracle 9i 在Red Hat Linux 7.3下的安装
- VC中坐标系的建立
- EJB3持久化规范(第二章)