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

发布于 2024-08-24 07:35:40 字数 2634 浏览 9 评论 0原文

我已经以与有关它的博客文章非常相似的方式进行了设置,但是在启动其中一个队列时出现错误。

我的程序不会自动创建 msmq://localhost/colin_console_queue

我相当确定我只是没有做正确的事情,但我不知道我遗漏了什么。

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

如果我更改两个网址以指向同一个队列,则应用程序基本上可以工作,但我相当确定这不是我应该做的。我查看了星巴克示例应用程序以了解它的功能,但它似乎使用代码中的硬编码路径进行了大量设置。

<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

I've setup things in a pretty similar way to the blog posts about it but I'm getting an error when at start up about one of the queues.

The msmq://localhost/colin_console_queue doesn't get created automatically by my program.

I'm fairly sure I'm just not doing something right but I don't know what I've omitted.

I did discover an 'DisableAutoQueueCreation' attribute and I tried setting it to false on the various config elements and I even discovered it was available as a property on the RhinoServiceBusFacility so I tried setting it there too. Unfortunately none of that seemed to work.

If I change the two urls to point to the same Queue the app basically works but I'm fairly sure that's not what I'm supposed to do. I looked at the Starbucks example app to see what it does but it appears to do a lot of setup using hard coded paths in the code.

<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>

Here's my test program I'm using to figure out how to use the Queue.

    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();
        }
    }

Here is the error I get,

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生漫 2024-08-31 07:35:40

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

不过,我的示例程序存在很大缺陷,因此我完全重写了内容并使用单向队列来确保我正确理解它(我想我做到了!)。我也许会在某个时候举出这个例子,因为我确实在理解这一切方面遇到了一些困难。

Thanks to Ayende (via email) the answer turns out to be because the queue you listen to (the one mentioned in the bus tag) is the only one you're responsible for creating automatically.

My example program is quite flawed though so I rewrote things completely and made use of the one way queue to ensure I understood it properly (well I think I do!). I'll perhaps put up the example at some point because I certainly had a bit of difficulty grokking it all.

孤单情人 2024-08-31 07:35:40

一般来说,Web 应用程序不应该对像队列服务器的消息队列配置这样基础设施的核心部分执行管理操作。真的。正常的管理指南 - 这就是为什么程序员可能认为有人不会尝试这样做。

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

手动设置队列。

Well, in general a web application should not do administrative action on something as ccentral to the infrastructure as the message queueing configuration of a queueing server. Really. Normal administrative guidleines - which is why the programmers probably did not think someoen would even try that.

See, there may be more to setting u pthe queue than you think of ;) Like configuring it.

Set up the queues manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文