The www.cloudamqp.com website is not exactly a PaaS cloud platform, but we need to introduce it to understand the next recipe.
CloudAMQP is a RabbitMQ service. You can use this service to avoid management and hardware costs. There are five plans available at http://www.cloudamqp.com/plans.html that you can choose from. The Little Lemur plan is free and is perfect for trying this service.
To try this recipe, you need to register an account on CloudAMQP; the registration is free.
<dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId> <version>2.8.1</version> </dependency>
Producer
class that creates and uses the queue called myorders_11
.Consumer
class that creates and uses the queue called myorders_11
.You can find the source code at Chapter11/Recipe01/
.
After creating your account (step 1), you can start using a RabbitMQ instance.
CloudAMQP service, by default, runs on Amazon AWS, and you have to choose the AWS data center (as we have seen in the previous chapter).
Go to the Instance Details page to see your connection parameters:
In the source code example, we had created a producer and a consumer, bound to the queue myorders_11
. The example sends a simple message to the queue, using the producer, and receives the message using the consumer.
To test this example, you can pass the CloudAMQP URL as a parameter in the following manner:
java -cp rabbitmq-client.jar:Recipe01-0.0.1-SNAPSHOT.jar rmqexample.Consumer amqp://oxxx:[email protected]/oibyfhxg
CloudAMQP is a very complete RabbitMQ service cloud. You can find all the clients and other cloud integrations at http://www.cloudamqp.com/docs.html.