如何检查消息队列是否已存在?
我有2个不同的应用程序,一个创建队列,另一个从该队列读取.
因此,如果我首先运行从队列中读取的客户端,而不是崩溃.
所以为了避免我想首先检查队列是否存在.
这是我如何读取队列的代码片段:
QueueingBasicConsumer <ConsumerName> = new QueueingBasicConsumer(<ChannelName>);
<ChannelName>.BasicConsume("<queuename>", null, <ConsumerName>);
BasicDeliverEventArgs e = (BasicDeliverEventArgs)<ConsumerName>.Queue.Dequeue();
Run Code Online (Sandbox Code Playgroud) while (true)
{
BasicDeliverEventArgs e = (BasicDeliverEventArgs)Consumer.Queue.Dequeue();
IBasicProperties properties = e.BasicProperties;
byte[] body = e.Body;
Console.WriteLine("Recieved Message : " + Encoding.UTF8.GetString(body));
ch.BasicAck(e.DeliveryTag, false);
}
Run Code Online (Sandbox Code Playgroud)
这是我们通过订阅检索消息时所做的事情.我们使用While循环,因为我们希望消费者不断地听...如果我想让这个甚至基于......那就是当时新消息到达队列的时候只有消费者应该消费消息..或任何类似的事件..
我正在升级 NHibernate、Castle.Core、Castle.Windsor(从 2.5 到 3.3)
IIS 版本:7.5
我的 web.config 中有这个
<configuration>
<system.web>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor"/>
</modules>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当我运行我的 Web 应用程序时,我会立即获得运行时错误页面,没有任何异常......并且在检查事件日志后我发现了这一点,
异常信息:异常类型:ConfigurationErrorsException 异常消息:无法从程序集“Castle.Windsor”加载类型“Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule”。在 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode 节点, Boolean checkAptcaBit, Boolean ignoreCase) 在 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) 在 System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement)
在 System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) 在 System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) 在 System.Web.HttpApplication.GetModuleCollection(IntPtr)应用上下文)
在 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, …