public void Send(TransportMessage message, SendOptions sendOptions) { Address destination = null; try { destination = DetermineDestination(sendOptions); var connectionInfo = connectionStringProvider.GetForDestination(sendOptions.Destination); var queue = new TableBasedQueue(destination, connectionInfo.Schema); if (sendOptions.EnlistInReceiveTransaction) { SqlTransaction currentTransaction; if (connectionStore.TryGetTransaction(connectionInfo.ConnectionString, out currentTransaction)) { queue.Send(message, sendOptions, currentTransaction.Connection, currentTransaction); } else { SqlConnection currentConnection; if (connectionStore.TryGetConnection(connectionInfo.ConnectionString, out currentConnection)) { queue.Send(message, sendOptions, currentConnection); } else { using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString)) { queue.Send(message, sendOptions, connection); } } } } else { // Suppress so that even if DTC is on, we won't escalate using (var tx = new TransactionScope(TransactionScopeOption.Suppress)) { using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString)) { queue.Send(message, sendOptions, connection); } tx.Complete(); } } } catch (SqlException ex) { if (ex.Number == 208) { ThrowQueueNotFoundException(destination, ex); } ThrowFailedToSendException(destination, ex); } catch (Exception ex) { ThrowFailedToSendException(destination, ex); } }