rabbitmq-tutorials/java
2018-08-09 14:41:18 -07:00
..
.idea Remove Puka port 2015-11-24 01:47:04 +03:00
EmitLog.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
EmitLogDirect.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
EmitLogHeader.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
EmitLogTopic.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
NewTask.java Don't use queueing consumer in Java tutorials 2015-08-04 14:19:28 +03:00
README.md Update Java build instructions 2017-01-24 17:07:22 +01:00
ReceiveLogHeader.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
ReceiveLogs.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
ReceiveLogsDirect.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
ReceiveLogsTopic.java Use the BuiltinExchangeType instead of string literals in Java examples 2017-03-21 09:45:20 +01:00
recompile.sh Update Java build instructions 2017-01-24 17:07:22 +01:00
Recv.java Don't use queueing consumer in Java tutorials 2015-08-04 14:19:28 +03:00
RPCClient.java Make RPCClient a little more interesting 2018-08-09 14:41:18 -07:00
RPCServer.java Use dedicated reply queue for RPC client 2018-08-07 18:04:31 +02:00
Send.java Don't use queueing consumer in Java tutorials 2015-08-04 14:19:28 +03:00
Worker.java Don't use queueing consumer in Java tutorials 2015-08-04 14:19:28 +03: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 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