RabbitMQ - Get started

Deploy RabbitMQ

To get started, go to ITCare and search for your target global service where you'll create your new RabbitMQ cluster.

Search for your Global Service in the top search bar and click on it to display its information page.

Once in your Global Service, click on the Create Resource button, select RabbitMQ and the required version.

Fill in the form:

  • Select a topology

  • Define the name of the future cluster

  • If Cluster topology : Select the number of brokers (3+)

  • Sizing

  • Storage required on each broker

  • Target location

  • Target network

  • Management options (backup, monitoring, 24/7, remote site replication)

Click Next once all fields have been completed.

In the next step, enter the password for the super user account to be supplied, then click Next.

Passwords are not saved by cegedim.cloud. Be sure to save your password!

Review the summary before submitting the form.

Provisioning can take up to 2 hours, depending on the current automation load.

Once the deployment is ready, you'll be notified by e-mail.

Start a cluster

At the top of the cluster page, click on the Manage button, then on Start and confirm.

Cluster startup starts all virtual machines attached to the cluster.

An e-mail notification will be sent when the service is activated.

Stop a cluster

At the top of the cluster page, click on the Manage button, then on Stop.

Enter an RFC number for tracking (optional). Click on Submit.

Shutting down a cluster will stop all virtual machines attached to the cluster, and monitoring will be disabled.

An e-mail notification will be sent when the cluster is shut down.

Resize nodes

At the top of the cluster page, click on the Manage button, then on Resize.

Select the nodes you wish to resize and select the new size (cpu/ram).

Each node will be resized and restarted sequentially.

An e-mail notification will be sent when all nodes have been resized.

Delete a cluster

At the top of the cluster page, click on the Manage button, then on Delete. This will stop and delete all virtual machines.

Please note that this action is not recoverable!

Enter an RFC number for tracking (optional), then click Submit.

An e-mail notification will be sent when the cluster is deleted.

How to manage RabbitMQ ?

Management UI

Once your deployment is ready, you can access the management UI for your deployment from ITCare.

The link is available in the Configuration panel of your deployment.

HTTP API

RabbitMQ can also be managed through API.

Once you get the link to your Management UI, the API is available by just adding /api at the end of the URL.

To get more information about using the API, click here :

How to produce messages in Python ?

This section will provide examples of Python code to produce messages to a simple queue or a quorum queue.

Of course, you can use the coding langage of your choice or any middleware that support AMQP.

Also, if AMQPS is enabled (TLS/SSL), extra configuration is needed. There is also an example for that.

Simple queue

#!/usr/bin/python3
import pika
 
credentials = pika.PlainCredentials('user','password')
connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='hostname', credentials=credentials))
channel = connection.channel()
 
channel.queue_declare(queue='simple-queue')
 
channel.basic_publish(exchange="", routing_key='simple-queue', body='Hello World!')
print(" [x] Sent 'Hello World!'")
 
connection.close()

Quorum queue

Highly recommended in a cluster setup for maximum resiliency !

#!/usr/bin/python3
import pika
 
credentials = pika.PlainCredentials('user','password')
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='hostname', credentials=credentials))
channel = connection.channel()
 
channel.queue_declare(queue="quorum-queue",durable=True,arguments={"x-queue-type": "quorum"})
 
channel.basic_publish(exchange="", routing_key='quorum-queue', body='Hello World!')
print(" [x] Sent 'Hello World!'")
 
connection.close()

AMQPS

When TLS/SSL is enabled for AMQP procotol, the certificate must be handled by either declaring it or adding it to your certificate store.

#!/usr/bin/python3
import pika
import ssl
 
logging.basicConfig(level=logging.INFO)
context = ssl.create_default_context(cafile="/path/to/certificate/my-certificate.pem")
ssl_options = pika.SSLOptions(context, "hostname")
credentials = pika.PlainCredentials('user','password')
conn_params = pika.ConnectionParameters(host='hostname', port=5671, ssl_options=ssl_options, credentials=credentials)
 
with pika.BlockingConnection(conn_params) as conn:
    ch = conn.channel()
    ch.queue_declare(queue="quorum-queue",durable=True,arguments={"x-queue-type": "quorum"})
    ch.basic_publish(exchange="", routing_key='quorum-queue', body='Hello World!')
    print(" [x] Sent 'Hello World!'")
 
connection.close()

How to consume messages in Python ?

This section will provide examples of Python code to consume messages.

#!/usr/bin/python3
import pika, sys, os
 
def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
 
def main():
    credentials = pika.PlainCredentials('user','password')
    connection = pika.BlockingConnection(pika.ConnectionParameters(host='hostname', credentials=credentials))
 
    channel = connection.channel()
 
    # Simple queue
    # channel.queue_declare(queue='hello')
    # channel.basic_consume(queue="hello", on_message_callback=callback, auto_ack=True)
 
    # Quorum queue
    channel.queue_declare(queue="quorum-queue",durable=True,arguments={"x-queue-type": "quorum"})
    channel.basic_consume(queue="quorum-queue", on_message_callback=callback, auto_ack=True)
 
    print(' [*] Waiting for messages. To exit press CTRL+C')
    channel.start_consuming()
 
if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        print('Interrupted')
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)

Last updated