Simon
Simon

Reputation: 34840

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

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.

Upvotes: 1

Views: 811

Answers (2)

Adam Fyles
Adam Fyles

Reputation: 6050

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;

Upvotes: 2

Simon
Simon

Reputation: 34840

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

Upvotes: 0

Related Questions