In this post we are going to use vCO to create a RabbitMQ broker, exchange and a queue. We will then bind to the queue so that we can send messages to the queue and retrieve them.
Adding a Broker
In the vCO client go to the workflow tab and then Library > AMQP. Right-click the Add a broker workflow and set select Start Workflow. Give the broker a name and select Next.
Fill in the RabbitMQ host, leave the virtual host as / unless you want to change it and know what you’re doing. The credentials are guest / guest.
If the workflow is successful, you will see:
Declaring an Exchange
In the vCO client go to the workflow tab and then Library > AMQP. Right-click on Declare an exchange and select Start Workflow.
- Select Not Set and browse to your broker
- Expand AMQP and select your broker
- Select Select
Press Next and enter the following:
Press Submit and if it completes successfully, you’ll see a green check.
If you go to your RabbitMQ web interface, you’ll see the exchange we just created:
Declaring a Queue
In the vCO client go to the workflow tab and then go to Library > AMQP. Right-click on Declare a queue and select Start Workflow.
Select your broker as before:
Fill in the following info:
Select Submit and you should get a green check if the workflow completes successfully.
In the RabbitMQ web interface we can see the new queue:
Binding to the Queue
In the vCO client go to the workflow tab and then go to Library > AMQP. Right-click on Bind and select Start Workflow.
Select your broker and select Next:
Fill in the following and press Submit.
The routing key is “true.*.*.*.com.vmware.vcloud.event.blockingtask.create.vappDeploy”. See Notification Message Format for more information on this. Once we have blocking tasks in vCloud set up, every time a vApp is deployed, a blocking task will go into this queue. Now if we click on the queue in the RabbitMQ web interface, we will see the new binding:
Sending a message to the queue
In the vCO client go to the workflow tab and then go to Library > AMQP. Right-click on Send a text message and select Start Workflow.
Select your broker and select Next:
Fill in the following and select Next:
Type in a message and select Submit. Sometimes here Submit isn’t highlighted so you have to press Back then Submit
Back in the RabbitMQ web interface we see that a new message has arrived:
We can also scroll down to the Get messages section and press Get Messages.
Here we can see our message. Set Requeue to No so that the message is removed off of the queue.
vCloud Director Configuration
Let’s do something a little more interesting and configure vCloud Director (vCD) to send messages to RabbitMQ when a vApp is deployed. From the vCD portal, enter the following:
Configure the blocking task:
- Select the Administration menu item
- Select Extensibility
- Check Start vApp (Deploy from API)
- Press Apply
Go ahead and start any vApp. You’ll see the status change to Pending processing…
This time the payload has a lot of vCD related information such as the ids for the org, user, etc of the vApp that was attempted to be deployed:
You could work with this data in the current format, but it’s much easier to use the vCD Notification Package. This package will extract all the details from the blocking task and populate variables such as user, org, org vDC, etc. It also allows you to run vCO workflows where you can use the data that was extracted out of the blocking task to do whatever you want. For example, you could add the deployed system to a CMDB, call out to Infoblox to update the DNS, etc. You probably want to use a different blocking task (vApp creation) type for this however. There are two different types for creating vApps. I’ll cover the vCD Notification Package and creating RabbitMQ subscriptions from vCO in the next post.