How to configure ServiceBusEnvironment Connectivity mode declaritively

1k Views Asked by At

WCF service is hosted in IIS and uses netTCPRelayBinding.

At some locations the TCP ports are blocked and HTTP must be used. Other times TCP ports are open and this mode is preferred.

Thus, I'd like to be able to set the ConnectivityMode to AutoDetect (or to just HTTP) declaratively in the web.config file.

For self hosted WCF, this is easily done:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;

How is this done declaratively in web.config?

1

There are 1 best solutions below

0
On

At the moment there is no configuration element for this setting however in your web.config you could use AppSettings to set the value

<appSettings>
   <add key="ServiceBusConnectivityMode" value="Http" />
</appSettings>

In the code you would then read the key value and parse it into enum value

ServiceBusEnvironment.SystemConnectivity.Mode = (ConnectivityMode)Enum.Parse(typeof(ConnectivityMode), ConfigurationManager.AppSettings["ServiceBusConnectivityMode"])