Switch branches/tags
Nothing to show
Find file History


Java code for RabbitMQ tutorials

Here you can find the Java code examples from RabbitMQ tutorials.

To successfully use the examples you will need a running RabbitMQ server.


You'll need to download the following JAR files from Maven Central:

Copy those files in your working directory, along the tutorials Java files.

To compile you only need the Rabbitmq Java Client jar on the classpath.

To run them you'll need all the dependencies, see examples below.

Note: If you're on Windows, use a semicolon instead of a colon to separate items in the classpath.

You can set an environment variable for the jar files on the classpath e.g.

 $ export CP=.:amqp-client-4.0.2.jar:slf4j-api-1.7.21.jar:slf4j-simple-1.7.22.jar
 $ java -cp $CP Send

or on Windows:

 > set CP=.;amqp-client-4.0.2.jar;slf4j-api-1.7.21.jar;slf4j-simple-1.7.22.jar
 > java -cp %CP% Send


Tutorial one: "Hello World!":

$ javac -cp amqp-client-4.0.2.jar Send.java Recv.java

$ java -cp .:amqp-client-4.0.2.jar:slf4j-api-1.7.21.jar:slf4j-simple-1.7.22.jar Send
$ java -cp .:amqp-client-4.0.2.jar:slf4j-api-1.7.21.jar:slf4j-simple-1.7.22.jar Recv

Tutorial two: Work Queues:

$ javac -cp amqp-client-4.0.2.jar NewTask.java Worker.java

$ java -cp $CP NewTask
$ java -cp $CP Worker

Tutorial three: Publish/Subscribe

$ javac -cp amqp-client-4.0.2.jar EmitLog.java ReceiveLogs.java

$ java -cp $CP ReceiveLogs
$ java -cp $CP EmitLog