Here you can find the Java code examples from RabbitMQ tutorials.
To successfully use the examples you will need a RabbitMQ node running locally.
You can easily set this up by installing RabbitMQ.
- Note the source files are symbolic links to the java directory.
- Run pull-source-files.bat to replace symbolic link to the actual source file.
./pull-source-files.bat
# terminal tab 1
./gradlew -Pmain=Recv run
# terminal tab 2
./gradlew -Pmain=Send run
# terminal tab 1
./gradlew -Pmain=Worker run
# terminal tab 2
./gradlew -Pmain=Worker run
# terminal tab 3
./gradlew -Pmain=NewTask run --args "First Message"
./gradlew -Pmain=NewTask run --args "Second Message"
./gradlew -Pmain=NewTask run --args "Third Message"
./gradlew -Pmain=NewTask run --args "Fourth Message"
./gradlew -Pmain=NewTask run --args "Fifth Message"
# terminal tab 1
./gradlew -Pmain=ReceiveLogs run
# terminal tab 2
./gradlew -Pmain=ReceiveLogs run
# terminal tab 3
./gradlew -Pmain=EmitLog run
# terminal tab 1
./gradlew -Pmain=ReceiveLogsDirect run --args "warning error"
# terminal tab 2
./gradlew -Pmain=ReceiveLogsDirect run --args "info warning error"
# terminal tab 3
./gradlew -Pmain=EmitLogDirect run --args "info 'Run. Run. Or it will explode'"
./gradlew -Pmain=EmitLogDirect run --args "warning 'Run. Run. Or it will explode'"
./gradlew -Pmain=EmitLogDirect run --args "error 'Run. Run. Or it will explode'"
# terminal tab 1
# To receive all the logs:
./gradlew -Pmain=ReceiveLogsTopic run --args "#"
# To receive all logs from the facility "kern":
./gradlew -Pmain=ReceiveLogsTopic run --args "kern.*"
# Or if you want to hear only about "critical" logs:
./gradlew -Pmain=ReceiveLogsTopic run --args "*.critical"
# You can create multiple bindings:
./gradlew -Pmain=ReceiveLogsTopic run --args "kern.* *.critical"
# terminal tab 2
# And to emit a log with a routing key "kern.critical" type:
./gradlew -Pmain=EmitLogTopic run --args "kern.critical A critical kernel error"
# terminal tab 1
# Our RPC service is now ready. We can start the server:
./gradlew -Pmain=RPCServer run
# terminal tab 2
# To request a fibonacci number run the client:
./gradlew -Pmain=RPCClient run
# terminal tab 1
./gradlew -Pmain=PublisherConfirms run