惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
Google Online Security Blog
Google Online Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
WordPress大学
WordPress大学
博客园 - 聂微东
L
LINUX DO - 最新话题
月光博客
月光博客
小众软件
小众软件
T
Troy Hunt's Blog
A
Arctic Wolf
量子位
I
Intezer
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
S
Schneier on Security
Schneier on Security
Schneier on Security
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
有赞技术团队
有赞技术团队
N
News and Events Feed by Topic
美团技术团队
The Cloudflare Blog
P
Privacy International News Feed
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
N
News | PayPal Newsroom
Apple Machine Learning Research
Apple Machine Learning Research
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
Hacker News: Ask HN
Hacker News: Ask HN
雷峰网
雷峰网

博客园 - Forrest Gump

关于LINQ中数据库连接字符串的问题 项目开发经验-ASP.NET项目开发中的异常处理 关于模态窗口(showModalDialog)的专题【收藏】 C#面试题 C# 将数据导出到Excel汇总 关于Assembly.CreateInstance()与Activator.CreateInstance()方法 PowerDesigner概念设计模型(CDM)中的3种实体关系 C#基础概念二十五问 Microsoft .NET Pet Shop 4:将 ASP.NET 1.1 应用程序迁移到 2.0 用Inno Setup制作WEB程序安装包 冒泡法数组排序与 System.Array.Sort()排序性能比较 堆排序 (Heap sort) 合并排序法(Merge Sort) 希尔排序法 quick sort 关于switch的小技巧 C#中一些很基础但有经常导致错误的一些概念 Enterprise Library Step By Step系列(十六):使用AppSetting Application Block Enterprise Library Step By Step系列(十五):配置应用程序块——设计篇
创建基于消息队列(MSMQ)的异步日志
Forrest Gump · 2008-01-18 · via 博客园 - Forrest Gump


一.概述

Enterprise Library Step By Step系列里我们说过,日志和检测应用程序块主要由2部分组成:ClientDistributorClient负责创建消息,这些消息将由Distributor写入目标位置。Client根据分发策略(Distribution Strategies)发送消息到Distributor,在Application Block中提供了2个分发策略:In ProcessMSMQ,默认的是In Process策略。同步日志是在Client进程中完成的,而异步日志是利用了MSMQ来实现的,Client需要创建日志消息并发送到MSMQ消息队列。另外一个进程则等待到达的消息,并写入合适的日志接收池

应用程序块中包含一个Windows Service: MSMQ Distributor Service。当安装该服务后,该服务会在指定的时间间隔检测消息队列。

我们看一下日志和监测应用程序块处理的流程图:

 

二.安装并配置MSMQ Distributor Service

1.打开Visual Studio命令行工具,切换到目录(默认的企业库安装路径)C:\Program Files\Microsoft Enterprise Library\bin下,运行如下命令:

installutil /i MsmqDistributor.exe

注意:必须要以这种方式安装服务,否则安装不成功。

2.安装过程中会弹出一个设置服务登录对话框,要求输入用户名和密码。此时用户名和密码的形式必须以域用户的形式输入,用<.\username>的形式也是可以的,如下图所示:

 

3.启动服务。我们在服务管理器里面找到Enterprise Library Logging Distributor Service这项服务,手工启动它。

 

4.用文本编辑器打开MsmqDistributor.exe.config文件,删除如下这节:

<configurationSections>
    
<configurationSection name="loggingConfiguration" encrypt="false">
      
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="loggingConfiguration.config" />
      
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
        
<includeTypes />
     
</dataTransformer>
</configurationSection>

5.用Configuration Console, 打开 MsmqDistributor.exe.config 文件

MSMQ Distributor Service 添加到 Distributor Settings,如下图所示:

 

6.设定 MsmqPath 属性匹配 Client 的队列名,我们可以修改MsmqPath的值,但是该值必须与我们应用程序中的Client配置的一致。

 

三.使用MSMQ创建异步日志

1.我们前面说过,Client Settings 决定分发策略,一个Client的所有消息使用同一个策略。所以我们不能同时创建两个策略,必须先删除In Process后,才能创建MSMQ

 

2.创建MSMQ分发策略之后,注意队列名必须和我们刚才在第二节里面所说的一致:

 

3.其他的操作就跟我在Enterprise Library Step By Step系列里面写的一样了。