rabbitmq-tutorials/java-gradle
dependabot[bot] 07e0b0011d
chore(deps): bump org.mockito:mockito-core in /java-gradle
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.17.0 to 5.18.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v5.17.0...v5.18.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-version: 5.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-21 17:50:16 +00:00
..
gradle/wrapper Upgrade gradle version to 8.5 2024-05-19 16:17:50 +09:00
src/main/java Add Java Gradle project 2023-02-01 22:32:41 +09:00
.gitignore Add Java Gradle project 2023-02-01 22:32:41 +09:00
build.gradle chore(deps): bump org.mockito:mockito-core in /java-gradle 2025-05-21 17:50:16 +00:00
gradlew Add Java Gradle project 2023-02-01 22:32:41 +09:00
gradlew.bat Add Java Gradle project 2023-02-01 22:32:41 +09:00
pull-source-files.bat Add Java Gradle project 2023-02-01 22:32:41 +09:00
README.md Update README.md 2024-05-20 22:57:38 +09:00
settings.gradle Add Java Gradle project 2023-02-01 22:32:41 +09: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 RabbitMQ node running locally.

You can easily set this up by installing RabbitMQ.

Requirements

Linux

  • Note the source files are symbolic links to the java directory.

Windows

  • Run pull-source-files.bat to replace symbolic link to the actual source file.
./pull-source-files.bat

Code

Tutorial one: "Hello World!":

# terminal tab 1
./gradlew -Pmain=Recv run

# terminal tab 2
./gradlew -Pmain=Send run

Tutorial two: Work Queues:

# 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"

Tutorial three: Publish/Subscribe

# terminal tab 1
./gradlew -Pmain=ReceiveLogs run

# terminal tab 2
./gradlew -Pmain=ReceiveLogs run

# terminal tab 3
./gradlew -Pmain=EmitLog run

Tutorial four: Routing

# 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'"

Tutorial five: Topics

# 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"

Tutorial six: RPC

# 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

Tutorial seven: Publisher Confirms

# terminal tab 1
./gradlew -Pmain=PublisherConfirms run