使用RabbitMQ消耗来自ASP.net MVC 4的AMQP消息 [英] Consume AMQP messages from ASP.net MVC 4 using RabbitMQ

查看:238
本文介绍了使用RabbitMQ消耗来自ASP.net MVC 4的AMQP消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我要使用RabbitMQ从ASP.net MVC 4使用AMQP消息. 我将一个对象存储在 System.Web.HttpContext.Current.Application 中,该对象内部使用BackgroundWorker实例来侦听消息(该侦听器是在 Global.asax.cs 中创建的) )

Let's say that I want to consume AMQP messages from ASP.net MVC 4 using RabbitMQ. I store an object in System.Web.HttpContext.Current.Application which internally uses an instance of BackgroundWorker to listen for messages (the listener is created in Global.asax.cs)

这是实施此操作的好方法还是应该使用静态类/单例?我没有ASP.net MVC的经验,所以我不确定.也许ASP.net MVC 4不是最佳平台选择?你会推荐什么?

Is this a good way to implement this operation or should I use a static class / singleton? I am inexperienced in ASP.net MVC so I am uncertain. Maybe ASP.net MVC 4 is not the best platform choose? What would you recommend?

目标是能够从Web界面监视/记录消息流量,随意杀死/创建/配置消费者.

The goal is to be able to monitor/log message traffic, kill/create/configure consumers at will from a web interface.

这是我的第一篇Stackoverflow帖子,因为我相信研究会很好.但是,这次我想听听其他人,thx:)

This is my first stackoverflow post as I believe in good research. But, this time I would like to hear from other people, thx :)

推荐答案

在我看来,ASP.NET应用程序使RabbitMQ订阅者不佳.您最好将订户实现为Windows服务.

An ASP.NET application makes a poor RabbitMQ subscriber in my opinion. You are far better off implementing your subscriber as a windows service.

  1. This excellent post by Phil Haack gives some good reasons why should think twice about using the BackgroundWorker for any serious service.
  2. It means that you can monitor and maintain your subscriber independently of your web application. You can use all the out-of-the-box tools that windows gives you - task monitor, perf monitor - to understand how your service is behaving.
  3. You can scale your subscriber independently of your web application. You might need only one instance of your web application, but two of your subscriber. Having them as separate processes gives you that kind of finer grained control.

这篇关于使用RabbitMQ消耗来自ASP.net MVC 4的AMQP消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆