启动命令
/Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/mqnamesrv &
nohup /Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/mqbroker -n localhost:9876 &
/Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
/Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
/Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/mqshutdown broker
/Users/xuguangwu/code/rocketmq/distribution/target/apache-rocketmq/bin/mqshutdown namesrv
主要概念
- Producer
A producer sends messages generated by the business application systems to brokers. RocketMQ provides multiple paradigms of sending: synchronous, asynchronous and one-way. 发送业务系统生成的消息,支持多种发送模式
- Producer Group
一类 Producer 的集合名称,返类 Producer 通常发送一类消息,且发送逻辑一致。
-
Consumer
- PullConsumer
主动从broker拉取消息
- PushConsumer
通过回调接口触发消费消息
-
Consumer Group
消费同一topic,以达到容错和负载的目的。 Consumer Group is a great concept with which achieving goals of load-balance and fault-tolerance。
- Topic
Topic is a category in which producers deliver messages and consumers pull messages. Topics have very loose relationship with producers and consumers.
- Message
Message is the information to be delivered. A message must have a topic. A message may also have an optional tag and extra key-value pairs.
- Tag
With tag, messages with different purposes from the same business module may have the same topic and different tag. Tags would be helpful to keep your code clean and coherent, and tags also can facilitate the query system RocketMQ provides.
- Message Queue
Topic is partitioned into one or more sub-topics, “message queues”.
- Broker
消息中转角色,负责存储消息,转发消息,一般也称为Server
- Name Server
Name server serves as the routing information provider. Producer/Consumer clients look up topics to find the corresponding broker list. 消息路由信息存储
-
Message Model
- Clustering
一个 Consumer Group 中的 Consumer 实例平均分摊消费消息。 例如某个Topic有9条消息,其中一个Consumer Group有3个实例(可能是3个进程,或者3台机器),那么每个实例只消费其中的3条消息。
- Broadcasting
一条消息被多个Consumer消费,即使这些Consumer属亍同一个Consumer Group, 消息也会被Consumer Group中的每个Consumer都消费一次,广播消费中的Consumer Group概念可以讣为在消息划分方面无意义。
-
Message Order
When DefaultMQPushConsumer is employed, you may decide to consume messages orderly or concurrently.
- Orderly
Consuming messages orderly means messages are consumed the same order they are sent by producers for each message queue. If you are dealing with scenario that global order is mandatory, make sure the topic you use has only one message queue. If consuming orderly is specified, the maximum concurrency of message consuming is the number of message queues subscribed by the consumer group.
- Concurrently When consuming messages concurrently, maximum concurrency of message consuming is only limited by thread pool specified for each consumer client. Message order is no longer guaranteed in this mode.