代码之家  ›  专栏  ›  技术社区  ›  Colin Newell

为什么Rhino.ServiceBus不自动创建所有队列?

  •  1
  • Colin Newell  · 技术社区  · 16 年前

    我的设置方式与博客上关于它的帖子非常相似,但在启动时,关于其中一个队列的设置会出错。

    这个 msmq://localhost/colin_console_queue 不会被我的程序自动创建。

    我很肯定我做得不对,但我不知道我遗漏了什么。

    我确实发现了“disableautoqueuecreation”属性,并尝试在各种配置元素上将其设置为false,甚至发现它作为 RhinoServiceBusFacility 所以我也试着把它放在那里。不幸的是,这些似乎都不起作用。

    如果我改变两个URL指向同一个队列,应用程序基本上可以工作,但我很确定这不是我应该做的。我查看了星巴克的示例应用程序,看看它能做什么,但它似乎使用代码中的硬编码路径进行了很多设置。

    <facilities>
      <facility id="rhino.esb">
        <bus threadCount="1" numberOfRetries="5" endpoint="msmq://localhost/colin_console_queue_bus"
             logEndpoint="msmq://localhost/colin_console_queue_bus.log" />
        <messages>
          <add name="ConsoleApplication1" endpoint="msmq://localhost/colin_console_queue" />
        </messages>
      </facility>
    </facilities>
    

    这是我的测试程序,我用它来计算如何使用队列。

        static void Main(string[] args)
        {
            var container = new WindsorContainer(new XmlInterpreter());
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            if (args.Length > 0)
            {
                var bus = container.Resolve<IStartableServiceBus>();
                bus.Start();
                bus.Send(new EmailMessage { Message = args[0], To = "test" });
                bus.Dispose();
            }
            else
            {
                container.Register(AllTypes.FromAssembly(Assembly.GetExecutingAssembly()).BasedOn(typeof(IMessageConsumer)));
                var bus = container.Resolve<IStartableServiceBus>();
                bus.Start();
                Console.ReadLine();
                Console.WriteLine("Bus stopped");
                bus.Dispose();
            }
        }
    

    这是我得到的错误,

    Unhandled Exception: System.Transactions.TransactionException: Failed to send message to Uri: msmq://colin-pc/colin_console_queue ---> Rhino.ServiceBus.Exceptions.TransportException: The queue msmq://colin-pc/colin_console_queue does not exists
       at Rhino.ServiceBus.Msmq.OpenedQueue..ctor(QueueInfo info, MessageQueue queue, String url, Nullable`1 transactional) in D:\Work\rhino-esb\Rhino.ServiceBus\Msmq\OpenedQueue.cs:line 24
       at Rhino.ServiceBus.Msmq.QueueInfo.Open(QueueAccessMode access, IMessageFormatter formatter) in D:\Work\rhino-esb\Rhino.ServiceBus\Msmq\QueueInfo.cs:line 71
       at Rhino.ServiceBus.Msmq.QueueInfo.Open(QueueAccessMode access) in D:\Work\rhino-esb\Rhino.ServiceBus\Msmq\QueueInfo.cs:line 63
       at Rhino.ServiceBus.Msmq.MsmqTransport.SendMessageToQueue(Message message, Endpoint endpoint) in D:\Work\rhino-esb\Rhino.ServiceBus\Msmq\MsmqTransport.cs:line 303
    
    2 回复  |  直到 16 年前
        1
  •  3
  •   Colin Newell    16 年前

    多亏了Ayende(通过电子邮件)的帮助,答案是因为您所收听的队列(总线标签中提到的队列)是您唯一负责自动创建的队列。

    不过,我的示例程序有很大的缺陷,所以我完全重写了内容,并使用了单向队列来确保我正确理解它(我想我理解!)我可能会在某个时候举个例子,因为我确实有点困难。

        2
  •  0
  •   TomTom    16 年前

    一般来说,Web应用程序不应该对基础结构的中心(如队列服务器的消息队列配置)之类的内容执行管理操作。真的?普通的管理程序——这就是为什么程序员可能不认为有人会这么做的原因。

    请看,设置队列可能比您想象的要多得多;)比如配置队列。

    手动设置队列。

    推荐文章