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
精彩评论