﻿# Unobtrusive


## Code walk-through

There sample consists of the following projects:

 * **Client**: sends a request and a command to the server and handles a published event
 * **Server**: handles requests and commands, and publishes events
 * **Shared**: the shared message definitions

## Configuring conventions for unobtrusive mode

The `ConventionExtensions` class tells NServiceBus how to determine which types are message definitions by passing in custom conventions instead of using the `IMessage`, `ICommand`, or `IEvent` interfaces:

<!-- snippet: CustomConvention -->

```cs
public static void ApplyCustomConventions(this EndpointConfiguration endpointConfiguration)
{
    var conventions = endpointConfiguration.Conventions();

    conventions.DefiningCommandsAs(
        type =>
        type.Namespace != null &&
        type.Namespace.EndsWith("Commands"));

    conventions.DefiningEventsAs(
        type =>
        type.Namespace != null &&
        type.Namespace.EndsWith("Events"));

    conventions.DefiningMessagesAs(
        type => type.Namespace == "Messages");

    conventions.DefiningClaimCheckPropertiesAs(
        property => property.Name.EndsWith("ClaimCheck"));

    conventions.DefiningTimeToBeReceivedAs(
        type =>
        {
            if (type.Name.EndsWith("Expires"))
            {
                return TimeSpan.FromSeconds(30);
            }
            return TimeSpan.MaxValue;
        });
}
```

<!-- endsnippet -->

It also demonstrates how to configure conventions for the [data bus](/nservicebus/messaging/claimcheck/index.md) and [time-to-be-received](/nservicebus/messaging/discard-old-messages.md) features.
