开发者

How to get the Queue name that NServiceBus pulled the message from

开发者 https://www.devze.com 2022-12-31 06:36 出处:网络
I can use this code to get the return address. string returnAddress = Bus.CurrentMe开发者_JAVA技巧ssageContext.ReturnAddress;

I can use this code to get the return address.

string returnAddress = Bus.CurrentMe开发者_JAVA技巧ssageContext.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.


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.

String address = Configure.ConfigurationSource.GetConfiguration<MsmqTransportConfig>().InputQueue;


Seems i just get it injected by adding a property

public ITransport Transport { get; set; }

And then accessing

Transport.Address

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号