資源簡(jiǎn)介
activemq 傳送數(shù)據(jù)流發(fā)送文件,僅供參考

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?Apache.NMS;
using?Apache.NMS.ActiveMQ;
namespace?WindowsFormsApplication2
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????????InitProducer();
????????}
????????private?IConnectionFactory?factory;
????????
????????public?void?InitProducer()
????????{
????????????try
????????????{
????????????????//初始化工廠,這里默認(rèn)的URL是不需要修改的
????????????????factory?=?new?ConnectionFactory(“tcp://localhost:61616“);
????????????}
????????????catch
????????????{
????????????????lbmessage.Text?=?“初始化失敗!!“;
????????????}
????????}
????????private?void?btnConfirm_Click(object?sender?EventArgs?e)
????????{
????????????//通過工廠建立連接
????????????using?(IConnection?connection?=?factory.CreateConnection())
????????????{
????????????????//通過連接創(chuàng)建Session會(huì)話
????????????????using?(ISession?session?=?connection.CreateSession())
????????????????{
????????????????????//通過會(huì)話創(chuàng)建生產(chǎn)者,方法里面new出來的是MQ中的Queue
????????????????????IMessageProducer?prod?=?session.CreateProducer(new?Apache.NMS.ActiveMQ.Commands.ActiveMQQueue(“00001“));
????????????????????//創(chuàng)建一個(gè)發(fā)送的消息對(duì)象
????????????????????ITextMessage?message?=?prod.CreateTextMessage();
????????????????????//給這個(gè)對(duì)象賦實(shí)際的消息
????????????????????message.Text?=?textmessage.Text;
????????????????????//設(shè)置消息對(duì)象的屬性,這個(gè)很重要哦,是Queue的過濾條件,也是P2P消息的唯一指定屬性
????????????????????message.Properties.SetString(“filter“?“demo“);
????????????????????//生產(chǎn)者把消息發(fā)送出去,幾個(gè)枚舉參數(shù)MsgDeliveryMode是否長(zhǎng)鏈,MsgPriority消息優(yōu)先級(jí)別,發(fā)送最小單位,當(dāng)然還有其他重載
????????????????????prod.Send(message?MsgDeliveryMode.NonPersistent?MsgPriority.Normal?TimeSpan.MinValue);
????????????????????lbmessage.Text?=?“發(fā)送成功!!“;
????????????????????textmessage.Text?=?““;
????????????????????textmessage.Focus();
????????????????}
????????????}
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????this.openFileDialog1.OpenFile();
????????}
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????753664??2013-05-31?17:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.ActiveMQ.dll
?????文件????3638784??2013-05-31?17:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.ActiveMQ.pdb
?????文件?????541193??2013-05-31?17:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.ActiveMQ.xm
?????文件??????81920??2013-05-20?17:37??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.dll
?????文件?????220672??2013-05-20?17:37??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.pdb
?????文件?????145105??2013-05-20?17:37??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Apache.NMS.xm
?????文件??????10752??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
?????文件??????22016??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
?????文件??????22704??2016-04-12?15:03??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
?????文件????????490??2015-07-10?19:01??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
?????文件???????2501??2016-04-01?13:49??WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs
?????文件???????4015??2016-04-01?13:49??WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs
?????文件???????6020??2016-04-01?13:49??WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx
?????文件???????1231??2016-04-05?10:54??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7039??2016-04-05?14:32??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1347??2016-04-12?15:03??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
?????文件????????869??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache
?????文件??????10752??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe
?????文件????????180??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources
?????文件??????22016??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.pdb
?????文件????????180??2016-04-11?16:55??WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Properties.Resources.resources
?????文件????????505??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Program.cs
?????文件???????1372??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Properties\AssemblyInfo.cs
?????文件???????2900??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.Designer.cs
?????文件???????5612??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.resx
?????文件???????1111??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.Designer.cs
?????文件????????249??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.settings
?????文件???????4225??2016-04-05?14:33??WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2.csproj
?????文件???????1041??2016-03-30?14:37??WindowsFormsApplication2\WindowsFormsApplication2.sln
????..A..H.?????31744??2016-04-12?15:04??WindowsFormsApplication2\WindowsFormsApplication2.v12.suo
............此處省略12個(gè)文件信息
評(píng)論
共有 條評(píng)論