How do I get to/accesss "readOnlySettings" SuppressDistributedTransactions

I’m using NSBHost and NSB 6.x.

I’ve been digging through the NSB code for awhile and haven’t found a way to get to these settings.

My goal is to find if Distributed transactions are suppressed for a given endpoint. FYI, I’m using RabbitMQ transport and NHibernate persistence.

Thanks!

You can have a custom feature accessing this information

class MyFeature : Feature
{
	public MyFeature()
	{
		EnableByDefault();
	}
	
	protected override void Setup(FeatureConfigurationContext context)
	{
		var consistency = context.Settings.GetRequiredTransactionModeForReceives();
	}
}
1 Like

Thanks @SeanFeldman!

@mgmccarthy Could you please share your use case? Seems like you are doing something infrastructural that can be of interest for others.

@ramonsmits, I’m simply trying to make sure there is no chance of any transaction being escalated to a distributed transaction.

I believe you can get information not only how @SeanFeldman mentioned, but also by looking at the key/value pairs in Settings:

context.Settings.TryGet("Transactions.SuppressDistributedTransactions", out bool suppressDistributedTransactions);
context.Settings.TryGet("Transactions.DoNotWrapHandlersExecutionInATransactionScope", out bool doNotWrapHandlersExecutionInATransactionScope);

I’m using RabbitMQ for the broker, which automatically sets the TransactionMode to ReceiveOnly. However, if MSDTC is installed on the machine on which you’re running an endpoint, and that endpoint write business data to persistence (in this case, Sql Server), then that handler does any type of message dispatch(es), I believe that automatically escalates the transaction to a distributed transaction (b/c both a database and a queue in the same logical transaction in the handler code).

@mgmccarthy while you’re correct that you can directly look up the values in the Settings, I would not recommend doing so. In a long term, those string based key identified values can be changed. It’s better to go through designated APIs when those are available. And when not, raise a request.

1 Like