Skip to content

Files

This branch is 823 commits behind rabbitmq/rabbitmq-tutorials:main.

java

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 23, 2015
Mar 21, 2017
Mar 21, 2017
Mar 21, 2017
Mar 21, 2017
Aug 4, 2015
Jan 24, 2017
Jan 24, 2017
Jan 22, 2017
Mar 21, 2017
Mar 21, 2017
Mar 21, 2017
Mar 21, 2017
Aug 4, 2015
Aug 4, 2015
Aug 4, 2015
Jan 24, 2017

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.

Requirements

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

Code

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