rabbitmq-tutorials/java
2011-07-04 17:29:15 +01:00
..
EmitLog.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
EmitLogDirect.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
EmitLogTopic.java Exceptions and closing in finally 2011-04-28 18:04:46 +01:00
NewTask.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
README.md AMQP.BasicProperties uses Builder in java client 2.5.0 2011-07-04 17:29:15 +01:00
ReceiveLogs.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
ReceiveLogsDirect.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
ReceiveLogsTopic.java Exceptions and closing in finally 2011-04-28 18:04:46 +01:00
Recv.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
RPCClient.java AMQP.BasicProperties uses Builder in java client 2.5.0 2011-07-04 17:29:15 +01:00
RPCServer.java AMQP.BasicProperties uses Builder in java client 2.5.0 2011-07-04 17:29:15 +01:00
Send.java Tidied Exceptions 2011-04-05 17:53:15 +01:00
Worker.java Tidied Exceptions 2011-04-05 17:53:15 +01:00

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 RabbitMQ java client library package, and check its signature as described there. Unzip it into your working directory and ensure the JAR files from the unzipped directory are placed in your working directory:

$ unzip rabbitmq-java-client-bin-*.zip
$ cp rabbitmq-java-client-bin-*/*.jar ./

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=.:commons-io-1.2.jar:commons-cli-1.1.jar:rabbitmq-client.jar
 $ java -cp $CP Send

or on Windows:

 > set CP=.;commons-io-1.2.jar;commons-cli-1.1.jar;rabbitmq-client.jar
 > java -cp %CP% Send

Code

Tutorial one: "Hello World!":

$ javac -cp rabbitmq-client.jar Send.java Recv.java

$ java -cp .:commons-io-1.2.jar:commons-cli-1.1.jar:rabbitmq-client.jar Send
$ java -cp .:commons-io-1.2.jar:commons-cli-1.1.jar:rabbitmq-client.jar Recv

Tutorial two: Work Queues:

$ javac -cp rabbitmq-client.jar NewTask.java Worker.java

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

Tutorial three: Publish/Subscribe

$ javac -cp rabbitmq-client.jar EmitLog.java ReceiveLogs.java

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