zoukankan      html  css  js  c++  java
  • C#操作消息队列的代码开发者在线 Builder.com.cn 更新时间:20080720作者: 来源:

    C#操作消息队列的代码开发者在线 Builder.com.cn更新时间:2008-07-20作者:来源:本文关键词:队列C#应用C#这是一个关于C#操作消息队列的代码,给新手朋友学习下,并不是很难,相信大家看看就能明白的。

    以下是引用片段:
    public class QueueManage
    {
    ///
    /// 发送对象到队列中
    ///
    ///
    队列名称,因为队列名称在一个应用中应该不改变的,所以大家最好写在配置文件中
    ///
    要发出去的对象
    public static void SendQueue(string QueuePath,MyBase.SmsQueue sq)
    {
    System.Messaging.MessageQueue mqSend=new System.Messaging.MessageQueue(QueuePath,false);
    EnsureQueueExists(QueuePath);
    mqSend.Send(sq);
    }
    ///
    /// 检查队列,如果队列不存在,则建立
    ///
    ///
    队列名称
    private static void EnsureQueueExists(string path)
    {
    if(!MessageQueue.Exists(path))
    {
    if(!MessageQueue.Exists(path))
    {
    MessageQueue.Create(path);
    MessageQueue mqTemp=new MessageQueue(path);
    mqTemp.SetPermissions("Everyone",System.Messaging.MessageQueueAccessRights.FullControl);
    ///不知道该给什么样的权限好,所以就给了Everone全部权限了,当然大家最好自己控制一下
    }
    }
    }
    ///
    /// 从队列中取出对象列表
    ///
    ///
    队列名称
    public static System.Collections.ArrayList GetMessage(string QueuePath)
    {
    MyBase.SmsQueue sq=new MyBase.SmsQueue();
    System.Messaging.MessageQueue mq=new System.Messaging.MessageQueue(QueuePath,false);
    mq.Formatter=new XmlMessageFormatter(new Type[] );
    System.Messaging.Message[] arrM=mq.GetAllMessages();
    mq.Close();
    System.Collections.ArrayList al=new System.Collections.ArrayList();
    foreach(System.Messaging.Message m in arrM)
    {
    sq=(TimeFound.SmsGate.Base.SmsQueue)m.Body;
    al.Add(sq);
    }
    return al;
    }
    }



  • 相关阅读:
    JDE函数--获取当前登录人的描述
    JDE报表开发笔记(R5537011 收货校验统计表)
    JDE函数--GetUDC(B函数)
    JDE隐藏Constant等(Hide Object)
    Oracle “dba_tables”介绍
    word2013设置页面边框
    makefile--#的不正确使用
    CICS定时
    程序的命名
    UE上传到FTP,会多出些字符
  • 原文地址:https://www.cnblogs.com/zhiji6/p/1649402.html
Copyright © 2011-2022 走看看