1 Star 0 Fork 0

zhzhouq9/rabbitmq-tutorials

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

RabbitMQ Tutorials in Scala

This is a minimalistic Scala port of the RabbitMQ tutorials in Java. The port is admittedly quite close to Java in terms of code style. This is primarily to the fact that RabbitMQ Java client still supports JDK 6 and doesn't have a lambda-friendly API.

Compiling the Code

./mvnw compile

Running Examples

Hello World

Execute the following command to receive a hello world:

./mvnw exec:java -Dexec.mainClass="Recv"

Execute the following in a separate shell to send a hello world:

./mvnw exec:java -Dexec.mainClass="Send"

Work Queues

Send a message which will be finished immediately:

./mvnw exec:java -Dexec.mainClass="NewTask"

Send a message which need some second to execute each . is one second.

./mvnw exec:java -Dexec.mainClass="NewTask" -Dexec.args="rabbit1 ...."

To start a worker (run in a separate shell):

./mvnw exec:java -Dexec.mainClass="Worker"

Add more workers to the same queue, message will be distributed in the round robin manner.

Publish and Subscriber

./mvnw exec:java -Dexec.mainClass="ReceiveLogs"

./mvnw exec:java -Dexec.mainClass="EmitLog" -Dexec.args="rabbit1 msg1"

Routing

./mvnw exec:java -Dexec.mainClass="ReceiveLogsDirect" -Dexec.args="info warning error"

./mvnw exec:java -Dexec.mainClass="EmitLogDirect" -Dexec.args="error Run. Run. Or it will explode."

Topics

./mvnw exec:java -Dexec.mainClass="ReceiveLogsTopic" -Dexec.args="#"

./mvnw exec:java -Dexec.mainClass="ReceiveLogsTopic" -Dexec.args="kern.*"

./mvnw exec:java -Dexec.mainClass="ReceiveLogsTopic" -Dexec.args="*.critical"

./mvnw exec:java -Dexec.mainClass="ReceiveLogsTopic" -Dexec.args="kern.* *.critical"

./mvnw exec:java -Dexec.mainClass="EmitLogTopic" -Dexec.args="kern.critical A critical kernel error"

RPC

In one shell:

./mvnw exec:java -Dexec.mainClass="RPCServer"

In another shell:

./mvnw exec:java -Dexec.mainClass="RPCClient"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhzhouq9/rabbitmq-tutorials.git
git@gitee.com:zhzhouq9/rabbitmq-tutorials.git
zhzhouq9
rabbitmq-tutorials
rabbitmq-tutorials
master

搜索帮助