• C#操作MSMQ(消息队列)


    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Messaging;

    using System.Data;

    using System.Data.SqlClient;



    namespace msmq

    {

       
    class Program

        {

           
    staticvoid Main(string[] args)

            {

               
    string database = args[0];



               
    string path =".\private$\"+ args[1];



               
    if (!MessageQueue.Exists(path))

                    MessageQueue.Create(path);



               
    string strsql ="select md5 from video with(nolock) order by id";



               
    int i =0;

               
    using (SqlDataReader dr = SqlHelper.ExecuteReader(string.Format(System.Configuration.ConfigurationSettings.AppSettings["db"], database), CommandType.Text, strsql))

                {

                   
    while (dr.Read())

                    {

                        Console.WriteLine(
    --i);

                        SendMessage(path, dr[
    0].ToString(), string.Empty);

                    }

                    dr.Close();

                    Console.WriteLine(
    "完成");

                }

            }



           
    privatestaticvoid SendMessage(string path, string label, object body)

            {

               
    //new MessageQueue(path).Send(body, label);

               
    //return;

                MessageQueue mq =new MessageQueue(path);

                System.Messaging.Message msg
    =new System.Messaging.Message();

                msg.Label
    = label;

                msg.Body
    = body;

                msg.Recoverable
    =true;

                mq.Send(msg);

                msg
    =null;

                mq.Close();

                mq
    =null;

            }

        }

    }

  • 相关阅读:
    object对象
    addEventListener 和 attachEvent
    BOM常用对象
    动态原型
    鼠标移动图片放大效果(兼容IE8、多图)
    伪元素:before和:after
    javascript/js 判断是否安装flash player插件,提示安装方法。
    Form表单值转换为[{name:'',value}]键值对
    [转][网站、云服务与虚拟机]弄清负载均衡的机制
    C# Lazy Initialization
  • 原文地址:https://www.cnblogs.com/armyfai/p/3586860.html
Copyright © 2020-2023  润新知