RabbitMQ Services

Apcera provides the rabbitmq service type for integrating with RabbitMQ.

Creating RabbitMQ services using APC

The rabbitmq service gateway creates an internal RabbitMQ service to which you can bind jobs. For example, the following command creates a new RabbitMQ service named rabbitmq and binds the job named myapp to the rabbitmq service:

apc service create rabbitmq --type rabbitmq --job myapp

The myapp will have an environment variable named RABBITMQ_URI set on its container that defines a connection string to the RabbitMQ instance. For example: RABBITMQ_URI=amqp://169.254.0.12:10000/vh0. Each time a service is created, a new RabbitMQ job is created. Therefore, each app that uses RabbitMQ will get its own RabbitMQ server.

The RabbitMQ service type does not use a provider. You only have to create the service and the binding. See Requirements for using RabbitMQ services.

Using RabbitMQ services with persistence provider

The RabbitMQ service gateway supports the use of the persistence_provider option. You can use this option to provide a persistent backend for the RabbitMQ service.

For example, to do this using an [NFS provider](/services/types/:

apc service create rabbitmq --type rabbitmq -- --persistence_provider provider::/apcera/providers::apcfs

See Apcera File Share services for details on using NFS persistence.

Requirements for implementing RabbitMQ services

This section describes the requirements for implementing RabbitMQ services.

Service gateway

To use RabbitMQ services in your cluster, the rabbitmq service gateway is required.

To verify that you have the rabbitmq service gateway:

apc gateway list -ns /
Working in "/"
╭──────────┬──────────┬──────────────────────────┬─────────┬───────────╮
│ Name     │ Type     │ Namespace                │ Status  │ Instances │
├──────────┼──────────┼──────────────────────────┼─────────┼───────────┤
│ generic  │ generic  │ /apcera/service-gateways │ started │ 1/1       │
│ gnatsd   │ gnatsd   │ /apcera/service-gateways │ started │ 1/1       │
│ http     │ http     │ /apcera/service-gateways │ started │ 1/1       │
│ ipm      │ ipm      │ /apcera/service-gateways │ started │ 1/1       │
│ memcache │ memcache │ /apcera/service-gateways │ started │ 1/1       │
│ mongodb  │ mongodb  │ /apcera/service-gateways │ started │ 1/1       │
│ mysql    │ mysql    │ /apcera/service-gateways │ started │ 1/1       │
│ network  │ network  │ /apcera/service-gateways │ started │ 1/1       │
│ nfs      │ nfs      │ /apcera/service-gateways │ started │ 1/1       │
│ postgres │ postgres │ /apcera/service-gateways │ started │ 1/1       │
│ rabbitmq │ rabbitmq │ /apcera/service-gateways │ started │ 1/1       │
│ redis    │ redis    │ /apcera/service-gateways │ started │ 1/1       │
│ s3       │ s3       │ /apcera/service-gateways │ started │ 1/1       │
╰──────────┴──────────┴──────────────────────────┴─────────┴───────────╯

Policy

Policy is required to use a rabbitmq service gateway and to view that the persistence_provider option is enabled.

The following policy claims are supported:

on gateway::/apcera/service-gateways::rabbitmq {
  { permit use }
  { serviceParam persistence_provider }
}

The permit use claim lets you use the rabitmq service gateway.

The serviceParam persistence_provider claim lets you view the persistence provider.

For example, with the serviceParam persistence_provider option set and the corresponding policy claim in place, apc service show provides the following information:

apc service show rabbitmq
╭───────────────────────┬─────────────────────────────────────────╮
│ Service:              │ rabbitmq                                │
├───────────────────────┼─────────────────────────────────────────┤
│ FQN:                  │ service::/sandbox/admin::rabbitmq       │
│ Type:                 │ rabbitmq                                │
│ persistence_provider: │ provider::/apcera/providers::apcfs      │
│ Completion Status:    │ created                                 │
│                       │                                         │
│ Created by:           │ admin@apcera.me                         │
│ Created at:           │ 2016-04-05 05:23:41.019475444 +0000 UTC │
╰───────────────────────┴─────────────────────────────────────────╯

Without the serviceParam persistence_provider policy claim you only see the following, even if you set the --persistence_provider option when you created the service:

apc service show rabbitmq
╭────────────────────┬─────────────────────────────────────────╮
│ Service:           │ rabbitmq                                │
├────────────────────┼─────────────────────────────────────────┤
│ FQN:               │ service::/sandbox/admin::rabbitmq       │
│ Type:              │ rabbitmq                                │
│ Completion Status: │ created                                 │
│                    │                                         │
│ Created by:        │ admin@apcera.me                         │
│ Created at:        │ 2016-04-05 05:19:52.144944701 +0000 UTC │
╰────────────────────┴─────────────────────────────────────────╯

In addition, to consume RabbitMQ services, both the service and the job must have permit bind policy claims. See service binding policy examples.