• 大小: 683KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: activemq  发送文件  

资源简介

activemq 传送数据流发送文件,仅供参考

资源截图

代码片段和文件信息

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
            {
                //初始化工厂,这里默认的URL是不需要修改的
                factory = new ConnectionFactory(“tcp://localhost:61616“);

            }
            catch
            {
                lbmessage.Text = “初始化失败!!“;
            }
        }

        private void btnConfirm_Click(object sender EventArgs e)
        {
            //通过工厂建立连接
            using (IConnection connection = factory.CreateConnection())
            {
                //通过连接创建Session会话
                using (ISession session = connection.CreateSession())
                {
                    //通过会话创建生产者,方法里面new出来的是MQ中的Queue
                    IMessageProducer prod = session.CreateProducer(new Apache.NMS.ActiveMQ.Commands.ActiveMQQueue(“00001“));
                    //创建一个发送的消息对象
                    ITextMessage message = prod.CreateTextMessage();
                    //给这个对象赋实际的消息
                    message.Text = textmessage.Text;
                    //设置消息对象的属性,这个很重要哦,是Queue的过滤条件,也是P2P消息的唯一指定属性
                    message.Properties.SetString(“filter“ “demo“);
                    //生产者把消息发送出去,几个枚举参数MsgDeliveryMode是否长链,MsgPriority消息优先级别,发送最小单位,当然还有其他重载
                    prod.Send(message MsgDeliveryMode.NonPersistent MsgPriority.Normal TimeSpan.MinValue);
                    lbmessage.Text = “发送成功!!“;
                    textmessage.Text = ““;
                    textmessage.Focus();
                }
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            this.openFileDialog1.OpenFile();

        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     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.xml

     文件      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.xml

     文件      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个文件信息

评论

共有 条评论