<commit_before>---
title: Introduction to Fluent Configuration API in V3 and V4
summary: Introduction to NServiceBus Fluent Configuration API in V3 and V4
tags:
- NServiceBus
- Fluent Configuration
---

NOTE: This article refers to NServiceBus V3 and V4

Every NServiceBus endpoint that works properly relies on a configuration to determine settings and behaviors other than endpoint core functionalities.

### NServiceBus Host

NServiceBus provides its own [hosting service][1] that can be used to outsource the whole hosting boilerplate code without worrying about how to deal with Windows services.

When using the built-in hosting service, the endpoint configuration is specified using the `EndpointConfig` class, automatically created when adding NServiceBus packages via NuGet, and implementing one of the core interfaces that determine endpoint behavior:

* `As_AServer`: Indicates that the endpoint behaves as a server. It is configured as a transactional endpoint that does not purge messages on startup;
* `As_APublisher`: Indicates that the endpoint is a publisher that can publish events, and extends the server role. An endpoint configured as a publisher cannot be configured as client at the same time;
* `As_AClient`: Indicates that the endpoint is a client.  A client endpoint is configured as a non-transactional endpoint that purges messages on startup.

```c#
public class EndpointConfiguration : IConfigureThisEndpoint, As_AServer
{
	
}
```

**IConfigureThisEndpoint**

The class in the example above represents the main entry point of an NServiceBus endpoint. Under the hood this is determined by the fact that the class implements the `IConfigureThisEndpoint` interface that identifies the class responsible for holding the initial configuration for an endpoint.

At runtime, during the startup phase, NServiceBus scans all the types, looking for a class that implements the `IConfigureThisEndpoint` interface.

More about the [NServiceBus.Host](the-nservicebus-host).

### Configuration Customization

When NServiceBus endpoints are hosted using the built-in NServiceBus host, you can customize the default configuration by adding a class to the project that implements the `IWantCustomInitialization` interface. This class is invoked at runtime by the hosting process and is provided with the default configuration initialized by the host:

```c#
public class CustomConfiguration : IWantCustomInitialization
{
	public void Init()
	{
		var currentConfig = Configure.Instance;
	}
}
```

NOTE: Do not start the bus; the host will do it. *`(comment - expand on this topic a bit)`*

More about [configuration customization](customizing-nservicebus-configuration).

### Features 

NOTE: The following section applies to NServiceBus V4 (or later)

NServiceBus V4 has introduced the concept of features. A *feature* is a high level concept that encapsulates a set of settings related to a certain feature. Features can be enabled or disabled. Enabled features can be configured.<commit_msg>Update fluent-config-api-v3-v4-intro.md<commit_after>---
title: Introduction to Fluent Configuration API in V3 and V4
summary: Introduction to NServiceBus Fluent Configuration API in V3 and V4
tags:
- NServiceBus
- Fluent Configuration
---

NOTE: This article refers to NServiceBus V3 and V4

Every NServiceBus endpoint that works properly relies on a configuration to determine settings and behaviors other than endpoint core functionalities.

### NServiceBus Host

NServiceBus provides its own [hosting service][1] that can be used to outsource the whole hosting boilerplate code without worrying about how to deal with Windows services.

When using the built-in hosting service, the endpoint configuration is specified using the `EndpointConfig` class, automatically created when adding NServiceBus packages via NuGet, and implementing one of the core interfaces that determine endpoint behavior:

* `As_AServer`: Indicates that the endpoint behaves as a server. It is configured as a transactional endpoint that does not purge messages on startup;
* `As_APublisher`: Indicates that the endpoint is a publisher that can publish events, and extends the server role. An endpoint configured as a publisher cannot be configured as client at the same time;
* `As_AClient`: Indicates that the endpoint is a client.  A client endpoint is configured as a non-transactional endpoint that purges messages on startup.

```c#
public class EndpointConfiguration : IConfigureThisEndpoint, As_AServer
{
	
}
```

**IConfigureThisEndpoint**

The class in the example above represents the main entry point of an NServiceBus endpoint. Under the hood this is determined by the fact that the class implements the `IConfigureThisEndpoint` interface that identifies the class responsible for holding the initial configuration for an endpoint.

At runtime, during the startup phase, NServiceBus scans all the types, looking for a class that implements the `IConfigureThisEndpoint` interface.

More about the [NServiceBus.Host](the-nservicebus-host).

### Configuration Customization

When NServiceBus endpoints are hosted using the built-in NServiceBus host, you can customize the default configuration by adding a class to the project that implements the `IWantCustomInitialization` interface. This class is invoked at runtime by the hosting process and is provided with the default configuration initialized by the host:

```c#
public class CustomConfiguration : IWantCustomInitialization
{
	public void Init()
	{
		var currentConfig = Configure.Instance;
	}
}
```

NOTE: Do not start the bus; the host will do it.

More about [configuration customization](customizing-nservicebus-configuration).

### Features 

NOTE: The following section applies to NServiceBus V4 (or later)

NServiceBus V4 has introduced the concept of features. A *feature* is a high level concept that encapsulates a set of settings related to a certain feature. Features can be enabled or disabled. Enabled features can be configured.
{'fraction_non_alphanumeric': 0.04620517097581318, 'fraction_numerical': 0.003336113427856547, 'mean_word_length': 5.200620475698035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3744134', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1389, 'n_words': 797}