My Environment:
- RabbitMQ 3.3.4
- Spring Tool Suite 3.6.0 (But you can also use a plain Eclipse with m2e tooling installed)
- Ubuntu 12.04 LTS
Installing RabbitMQ
Download the deb package. Once its downloaded double-click it to open it in Ubuntu Software Center and install it. That's pretty much it. The message broker is now running with default configuration settings.You can double check the message broker is running (or start it) like so:
sudo invoke-rc.d rabbitmq-server startYou should see something like this:
* Starting message broker rabbitmq serverOther useful commands:
* message broker already running
sudo invoke-rc.d rabbitmq-server stop
sudo invoke-rc.d rabbitmq-server status
Setting up an Eclipse Project
You'll need a version of Eclipse with M2E installed. I used Spring Tool Suite simply because I already had it installed, and it includes M2E.Use the "New Maven Project" wizard to create a simple maven jar project. Then put the following stuff in its pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"The code from the tutorial can be used pretty much as is. Put it into your maven project's main source folder.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kdvolder.pivotal.io</groupId>
<artifactId>rabitmq-hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rabitmq-hello-world</name>
<description>rabitmq-hello-world</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.3.4</version>
</dependency>
</dependencies>
</project>
Running The Code
When you are done, you can run the two sample apps 'Send' and 'Recv' by right-clicking them in the Package Explorer and selecting "Run As >> Java Application".
If you just want to get the code and not copy-paste it together yourself. It is on github.