# `Testcontainers.RabbitMQContainer`
[🔗](https://github.com/testcontainers/testcontainers-elixir/blob/main/lib/container/rabbitmq_container.ex#L1)

Provides functionality for creating and managing RabbitMQ container configurations.

NOTE: The default starting command is `chmod 400 /var/lib/rabbitmq/.erlang.cookie; rabbitmq-server`.
`chmod 400 /var/lib/rabbitmq/.erlang.cookie` is necessary for the waiting strategy, which calls the command `rabbitmq-diagnostics check_running`; otherwise CLI tools cannot communicate with the RabbitMQ node.

NOTE: Currently untested, any developer who tries to add improvements on this container should consider moving this container implementation to a separate Elixir package.

# `t`

```elixir
@type t() :: %Testcontainers.RabbitMQContainer{
  check_image: term(),
  cmd: term(),
  force_reuse: term(),
  image: term(),
  password: term(),
  port: term(),
  reuse: term(),
  username: term(),
  virtual_host: term(),
  wait_timeout: term()
}
```

# `connection_parameters`

Returns the connection parameters to connect to RabbitMQ from the _host machine_.

## Parameters

- `container`: The active RabbitMQ container instance in the form of a %Container{} struct.

## Examples

    iex> RabbitMQContainer.connection_parameters(container)
    [
      host: "localhost",
      port: 32768,
      username: "guest",
      password: "guest",
      vhost: "/"
    ]

# `connection_url`

Generates the connection URL for accessing the RabbitMQ service running within the container.

This URI is based on the AMQP 0-9-1, and has the following scheme:
amqp://username:password@host:port/vhost

## Parameters

- `container`: The active RabbitMQ container instance in the form of a %Container{} struct.

## Examples

    iex> RabbitMQContainer.connection_url(container)
    "amqp://guest:guest@localhost:32768"
    iex> RabbitMQContainer.connection_url(container_with_vhost)
    "amqp://guest:guest@localhost:32768/vhost"

# `default_image`

Retrieves the default Docker image for the RabbitMQ container

# `default_image_with_tag`

Retrieves the default Docker image including tag for the RabbitMQ container

# `default_port`

Retrieves the default exposed port for the RabbitMQ container

# `new`

Creates a new `RabbitMQContainer` struct with default configurations.

# `port`

Returns the port on the _host machine_ where the RabbitMQ container is listening.

# `with_check_image`

Set the regular expression to check the image validity.

# `with_cmd`

Overrides the default command used for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_cmd(["sh", "-c", "rabbitmq-server"])
  iex> config.cmd
  ["sh", "-c", "rabbitmq-server"]

# `with_force_reuse`

# `with_image`

Overrides the default image use for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_image("rabbitmq:xyz")
  iex> config.image
  "rabbitmq:xyz"

# `with_password`

Overrides the default password used for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_password("rabbitmq")
  iex> config.password
  "rabbitmq"

# `with_port`

Overrides the default port used for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_port(1111)
  iex> config.port
  1111

# `with_reuse`

Set the reuse flag to reuse the container if it is already running.

# `with_username`

Overrides the default user used for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_username("rabbitmq")
  iex> config.username
  "rabbitmq"

# `with_virtual_host`

Overrides the default virtual host used for the RabbitMQ container.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_virtual_host("/")
  iex> config.password
  "/"

# `with_wait_timeout`

Overrides the default wait timeout used for the RabbitMQ container.

Note: this timeout will be used for each individual wait strategy.

## Examples

  iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_wait_timeout(60000)
  iex> config.wait_timeout
  60000

---

*Consult [api-reference.md](api-reference.md) for complete listing*
