# LavinMQHostingExtension Methods

- Package: [CommunityToolkit.Aspire.Hosting.LavinMQ](/reference/api/csharp/communitytoolkit.aspire.hosting.lavinmq.md)
- Type: [LavinMQHostingExtension](/reference/api/csharp/communitytoolkit.aspire.hosting.lavinmq/lavinmqhostingextension.md)
- Kind: `Methods`
- Members: `3`

Provides extension methods for configuring and adding a LavinMQ container as a resource within a distributed application using Aspire.Hosting. This enables connection, health checks, and specific configurations for LavinMQ instances.

## AddLavinMQ(IDistributedApplicationBuilder, string, int, int)

- Name: `AddLavinMQ(IDistributedApplicationBuilder, string, int, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<LavinMQContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.LavinMQ/LavinMQHostingExtension.cs#L33-L82)

Adds a LavinMQ container resource to the distributed application builder. Configures the resource with specified parameters and sets up health checks for the resource.

```csharp
public static class LavinMQHostingExtension
{
    public static IResourceBuilder<LavinMQContainerResource> AddLavinMQ(
        this IDistributedApplicationBuilder builder,
        string name,
        int amqpPort = 5672,
        int managementPort = 15672)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The distributed application builder to which the LavinMQ resource will be added.
- `name` (`string`)
  The name of the LavinMQ resource.
- `amqpPort` (`int`) `optional`
  The port number for the AMQP protocol. Default is 5672.
- `managementPort` (`int`) `optional`
  The port number for the management interface. Default is 15672.

## Returns

`IResourceBuilder<LavinMQContainerResource>` -- A resource builder for the LavinMQ container resource.

## Exceptions

- `DistributedApplicationException` -- Thrown when the resource addition fails or other errors occur during the process.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataBindMount(IResourceBuilder<LavinMQContainerResource>, string, bool)

- Name: `WithDataBindMount(IResourceBuilder<LavinMQContainerResource>, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<LavinMQContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.LavinMQ/LavinMQHostingExtension.cs#L114-L117)

Configures a bind mount for the LavinMQ container resource to allow data persistence. The method mounts a specified source path on the host to the container's data directory.

```csharp
public static class LavinMQHostingExtension
{
    public static IResourceBuilder<LavinMQContainerResource> WithDataBindMount(
        this IResourceBuilder<LavinMQContainerResource> builder,
        string source,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<LavinMQContainerResource>`)
  The resource builder for the LavinMQ container to which the data bind mount will be added.
- `source` (`string`)
  The source path on the host machine to bind mount to the container's data directory.
- `isReadOnly` (`bool`) `optional`
  Indicates if the bind mount should be configured as read-only. Default is false.

## Returns

`IResourceBuilder<LavinMQContainerResource>` -- An updated resource builder for the LavinMQ container resource with the configured data bind mount.

## Exceptions

- `ArgumentNullException` -- Thrown when the builder or source parameters are null.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataVolume(IResourceBuilder<LavinMQContainerResource>, string, bool)

- Name: `WithDataVolume(IResourceBuilder<LavinMQContainerResource>, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<LavinMQContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.LavinMQ/LavinMQHostingExtension.cs#L96-L98)

Configures a data volume for the LavinMQ container resource by specifying its name and read-only status.

```csharp
public static class LavinMQHostingExtension
{
    public static IResourceBuilder<LavinMQContainerResource> WithDataVolume(
        this IResourceBuilder<LavinMQContainerResource> builder,
        string name,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<LavinMQContainerResource>`)
  The resource builder for the LavinMQ container resource.
- `name` (`string`)
  The name of the data volume to be attached to the LavinMQ container resource.
- `isReadOnly` (`bool`) `optional`
  Indicates whether the data volume should be mounted as read-only. Default is false.

## Returns

`IResourceBuilder<LavinMQContainerResource>` -- The updated resource builder for the LavinMQ container resource.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
