如何获取 NServiceBus 从中拉取消息的队列名称
我可以使用此代码来获取返回地址。
string returnAddress = Bus.CurrentMessageContext.ReturnAddress;
但我如何获得消息的“收件人地址”。即 NServiceBus 从中提取消息的队列。
我查看了源代码,似乎 Bus.Transport.Address 是我想要的,但没有获得 Transport
注意:我位于消息处理程序的“Handle”方法中。
I can use this code to get the return address.
string returnAddress = Bus.CurrentMessageContext.ReturnAddress;
But how do i get the "to address" of the message. i.e. the Queue that NServiceBus pulled the message from.
I had a look through the source and it seems Bus.Transport.Address is what i want but there is no get on Transport
Note: I am within the "Handle" method of a message handler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该与您的 MsmqTransport 配置部分中的地址相同。您应该能够提取该部分并获取该值。
This should be the same address that is in your MsmqTransport configuration section. You should be able to pull that section and grab the value.
似乎我只是通过添加属性
然后访问
注意来注入它:事实证明,在最新的源代码中,ITransport 上没有属性“Address”。所以这个答案不正确:(
https://nservicebus.svn.sourceforge.net/svnroot/nservicebus/trunk/src/unicastTransport/NServiceBus.Unicast.Transport/ITransport.cs
Seems i just get it injected by adding a property
And then accessing
NOTE: turns out that in the latest source there is no property "Address" on ITransport. So this answer is not correct :(
https://nservicebus.svn.sourceforge.net/svnroot/nservicebus/trunk/src/unicastTransport/NServiceBus.Unicast.Transport/ITransport.cs