RocketMQ 是出自 A 公司的开源产品,用 Java 语言实现,在设计时参考了 Kafka,并做出了自己的一些改进,消息可靠性上比 Kafka 更好,目前,RocketMQ 的文档仍然不够丰富 1 2,社区仍然无法与 Kafka 比肩,但 A 公司已经推出了基于 RocketMQ 的云产品 3,相信未来 RocketMQ 也会有不错的发展。本文采用 RocketMQ 3.2.6 进行实验,由于 RocketMQ 与 Kafka 很相似,本文很多地方对两者做出了比较。
RocketMQ 由于借鉴了 Kafka 的设计,包括组件的命名也很多与 Kafka 相似,下面摘抄一段《RocketMQ 原理简介》中的介绍,可以与 Kafka 的命名比对一下,
《RocketMQ 原理简介》中还介绍了一些其他的概念,例如,广播消费和集群消费,广播消费是 Consumer Group 中对于同一条消息每个 Consumer 都消费,集群消费是 Consumer Group 中对于同一条消息只有一个 Consumer 消费。Kafka 采用的是集群消费,不支持广播消费(好吧,是我没有找到)。再例如,普通顺序消息和严格顺序消息,普通顺序消息在 Broker 重启情况下不会保证消息顺序性;严格顺序消息即使在异常情况下也会保证消息的顺序性。个人理解,所谓普通顺序消息,应该就是 Kafka 中的 Partition 级别有序,严格顺序消息,应该是 Topic 级别有序,但文中也提到,这样的有序级别是要付出代价的,Broker 集群中只要有一台机器不可用,则整个集群都不可用,降低服务可用性。使用这种模式,需要依赖同步双写,主备自动切换,但自动切换功能目前还未实现(我猜,自动切换仅仅是没开源吧)。说白了,严格顺序消息不具备生产可用性,自己玩玩还行,其应用场景主要是数据库 binlog 同步。
关于 RocketMQ 和 Kafka 的对比,可以参考 RocketMQ Wiki 中的文章 4,看看就行,不必较真。
顺序性的话题,刚才已经提到了一些,RocketMQ 的实现应该不弱于 Kafka。对于分区,RocketMQ 似乎有意弱化了这个概念,只有在 Producer 中有一个参数 defaultTopicQueueNums
,分区在 RocketMQ 中有时被称为队列。RocketMQ 的普通顺序消息模式,应该就是分区顺序性,这点与 Kafka 一致。
RocketMQ 实现高可用的方式有多种,《RocketMQ 用户指南》文档中提到的有:多主模式、多主多从异步复制模式、多主多从同步复制模式。多主模式下,性能较好,但是在 Broker 宕机的时候,该 Broker 上未消费的交易不可消费;多主多从异步复制模式,与 Kafka 的副本模式比较类似,主 Broker 宕机后,会自动切换到从 Broker,消息的消费不会出现间断;多主多从同步复制模式更进一步,采用同步刷盘的方式,避免了主 Broker 宕机带来的消息丢失,但是,目前不支持自动切换。
虽然 RocketMQ 提供了多种高可用方式,但是目前能生产使用的就只有多主多从异步复制模式,即使在这个模式上,其实现也比 Kafka 要差。因为 RocketMQ 的机制中,主从关系是人为指定的,主 Broker 上承担所有的消息派发,而 Kafka 的主从关系是通过选举的方式选出来的,每个分区的主节点都是不一样的,可以从不同的节点派发消息。Kafka 的模式是分散模式,有利于负载均衡,而且当一个 Broker 宕机的时候,只影响部分 Topic,而 RocketMQ 一旦主 Broker 宕机,会影响所有的 Topic。另外,Kafka 可以支持 Broker 间同步复制(通过设置 Broker 的 acks
参数),这样比的话,RocketMQ 就差太多了。
关于 RocketMQ 的介绍,网上的文章不算太多,也比较杂,《分布式开放消息系统(RocketMQ)的原理与实践》5 6 7这篇原理介绍的不错,推荐。
相比较 Kafka 而言,RocketMQ 提供的工具要少一些,如下,
1
2
3
4
5
6
7
8
9
|
bin/mqadmin
bin/mqbroker
bin/mqbroker.numanode0
bin/mqbroker.numanode1
bin/mqbroker.numanode2
bin/mqbroker.numanode3
bin/mqfiltersrv
bin/mqnamesrv
bin/mqshutdown
|
除了进程启停之外,常用的运维命令都在 mqadmin
中,详见《RocketMQ 运维指令》文档。我实验中常用的一些命令如下,
1
2
3
4
5
6
7
8
9
10
11
|
sh mqnamesrv &
sh mqbroker -c async-broker-a.properties &
sh mqbroker -c async-broker-a-s.properties &
sh mqadmin topicList -n
192.168.232.23:9876
sh mqadmin topicRoute -n
192.168.232.23:9876 -t TopicTestjjj
sh mqadmin clusterList -n
192.168.232.23:9876
sh mqadmin deleteTopic -c DefaultCluster -n
192.168.232.23:9876 -t TopicTestjjj
sh mqadmin consumerProgress -n
192.168.232.23:9876 -g ConsumerGroupNamecc4
sh mqadmin deleteSubGroup -c DefaultCluster -n
192.168.232.23:9876 -g ConsumerGroupNamecc4
sh mqadmin consumerConnection -n
192.168.232.23:9876 -g ConsumerGroupNamecc4
|
RocketMQ 使用了自己的 name server 来做调度(Kafka 用了 Zookeeper),使用 sh mqnamesrv
来启动,默认监听端口9876,sh mqnamesrv -m
可以查看所有默认参数,使用 -c xxxx.properties
参数来指定自定义配置。sh mqbroker
是用于启动 Broker 的命令,参数比较多,详细可以通过 sh mqbroker -m
查看默认参数,配置项细节后文再说。sh mqadmin
是运维命令入口,topicList
是列出所有 Topic;topicRoute
是列出单个 Topic 的详细信息;clusterList
是列出集群的信息;deleteTopic
是删除 Topic。consumerProgress
是查看消费者消费进度,deleteSubGroup
是删除消费者的订阅,consumerConnection
是查询消费者订阅的情况。
Broker 的配置是最多的,实验中我修改到的部分如下,其他使用默认,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
brokerClusterName=DefaultCluster
brokerIP1=
192.168.
232.23
brokerName=broker-a
brokerId=
0
namesrvAddr=
192.168.
232.23:
9876
listenPort=
10911
deleteWhen=
04
fileReservedTime=
120
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-a-async
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-a-async/commitlog
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
|
配置文件中的多数配置看例子就可以知道意思,挑几个说一下。brokerName
和 brokerId
, 同名的 Broker,ID 是0的是主节点,其他是从节点;deleteWhen
,删除文件时间点,默认凌晨4点;fileReservedTime
,文件保留时间,设置为120小时;brokerRole
,Broker 的角色,ASYNC_MASTER 是异步复制主节点,SYNC_MASTER 是同步双写主节点,SLAVE 是备节点。
其实,这些工具的写法也基本一致,都是先做一些检查,最后运行 Java 程序,JVM 系统上的应用应该差不多都这样。
RocketMQ 是用 Java 语言开发的,因此,其 Java API 相对是比较丰富的,当然也有部分原因是 RocketMQ 本身提供的功能就比较多。RocketMQ API 提供的功能包括,
单看功能的话,即使不算事务消息,也不算 Tag,RocketMQ 也远超 Kafka,Kafka 应该只实现了 Pull 模式消费 + 顺序消费这2个功能。RocketMQ 的代码示例在 rocketmq-example 中,注意,代码是不能直接运行的,因为所有的代码都少了设置 name server 的部分,需要自己手动加上,例如,producer.setNamesrvAddr("192.168.232.23:9876");
。
先来看一下生产者的 API,比较简单,只有一种,如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.common.message.MessageQueue;
import java.util.List;
public
class Producer {
public
static
void
main(String[] args)
throws MQClientException, InterruptedException {
DefaultMQProducer producer =
new DefaultMQProducer(
"ProducerGroupName");
producer.setNamesrvAddr(
"192.168.232.23:9876");
producer.start();
for (
int i =
0; i <
10; i++)
try {
{
Message msg =
new Message(
"TopicTest1",
// topic
"TagA",
// tag
"OrderID188",
// key
(
"RocketMQ "+String.format(
"%05d", i)).getBytes());
// body
SendResult sendResult = producer.send(msg,
new MessageQueueSelector() {
@Override
public MessageQueue
select(List
Integer id = (Integer) arg;
int index = id % mqs.size();
return mqs.get(index);
}
}, i));
System.out.println(String.format(
"%05d", i)+sendResult);
}
}
catch (Exception e) {
e.printStackTrace();
}
producer.shutdown();
}
}
|
可以发现,相比 Kafka 的 API,只多了 Tag,但实际上行为有很大不同。Kafka 的生产者客户端,有同步和异步两种模式,但都是阻塞模式,send
方法返回发送状态的 Future
,可以通过 Future
的 get
方法阻塞获得发送状态。而 RocketMQ 采用的是同步非阻塞模式,发送之后立刻返回发送状态(而不是 Future
)。正常情况下,两者使用上差别不大,但是在高可用场景中发生主备切换的时候,Kafka 的同步可以等待切换完成并重连,最后返回;而 RocketMQ 只能立刻报错,由生产者选择是否重发。所以,在生产者的 API 上,其实 Kafka 是要强一些的。
另外,RocketMQ 可以通过指定 MessageQueueSelector
类的实现来指定将消息发送到哪个分区去,Kafka 是通过指定生产者的 partitioner.class
参数来实现的,灵活性上 RocketMQ 略胜一筹。
再来看消费者的API,由于 RocketMQ 的功能比较多,我们先看 Pull 模式消费的API,如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
import com.alibaba.rocketmq.client.consumer.PullResult;
import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
import com.alibaba.rocketmq.client.consumer.store.RemoteBrokerOffsetStore;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.common.message.MessageExt;
import com.alibaba.rocketmq.common.message.MessageQueue;
public
class PullConsumer {
private
static
final Map
public
static
void
main(String[] args)
throws MQClientException {
DefaultMQPullConsumer consumer =
new DefaultMQPullConsumer(
"please_rename_unique_group_name_5");
consumer.setNamesrvAddr(
"192.168.232.23:9876");
consumer.start();
Set
for (MessageQueue mq : mqs) {
System.out.println(
"Consume from the queue: " + mq);
SINGLE_MQ:
while (
true) {
try {
long offset = consumer.fetchConsumeOffset(mq,
true);
PullResult pullResult =
consumer.pullBlockIfNotFound(mq,
null, getMessageQueueOffset(mq),
32);
if (
null != pullResult.getMsgFoundList()) {
for (MessageExt messageExt : pullResult.getMsgFoundList()) {
System.out.print(
new String(messageExt.getBody()));
System.out.print(pullResult);
System.out.println(messageExt);
}
}
putMessageQueueOffset(mq, pullResult.getNextBeginOffset());
switch (pullResult.getPullStatus()) {
case FOUND:
// TODO
break;
case NO_MATCHED_MSG:
break;
case NO_NEW_MSG:
break SINGLE_MQ;
case OFFSET_ILLEGAL:
break;
default:
break;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
consumer.shutdown();
}
private
static
void
putMessageQueueOffset(MessageQueue mq,
long offset) {
offseTable.put(mq, offset);
}
private
static
long
getMessageQueueOffset(MessageQueue mq) {
Long offset = offseTable.get(mq);
if (offset !=
null)
return offset;
return
0;
}
}
|
这部分的 API 其实是和 Kafka 很相似的,唯一不同的是,RocketMQ 需要手工管理 offset 和指定分区,而 Kafka 可以自动管理(当然也可以手动管理),并且不需要指定分区(分区是在 Kafka 订阅的时候指定的)。例子中,RocketMQ 使用 HashMap 自行管理,也可以用 OffsetStore
接口,提供了两种管理方式,本地文件和远程 Broker。这部分感觉两者差不多。
下面再看看 Push 模式顺序消费,代码如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
import com.alibaba.rocketmq.common.message.MessageExt;
public
class Consumer {
public
static
void main(String[] args) throws MQClientException {
DefaultMQPushConsumer consumer =
new DefaultMQPushConsumer(
"please_rename_unique_group_name_3");
consumer.setNamesrvAddr(
"192.168.232.23:9876");
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
consumer.subscribe(
"TopicTest1",
"TagA || TagC || TagD");
consumer.registerMessageListener(
new MessageListenerOrderly() {
AtomicLong consumeTimes =
new AtomicLong(
0);
@Override
public ConsumeOrderlyStatus consumeMessage(List
context.setAutoCommit(
false);
System.out.println(Thread.currentThread().getName() +
" Receive New Messages: " + msgs);
this.consumeTimes.incrementAndGet();
if ((
this.consumeTimes.
get() %
2) ==
0) {
return ConsumeOrderlyStatus.SUCCESS;
}
else
if ((
this.consumeTimes.
get() %
3) ==
0) {
return ConsumeOrderlyStatus.ROLLBACK;
}
else
if ((
this.consumeTimes.
get() %
4) ==
0) {
return ConsumeOrderlyStatus.COMMIT;
}
else
if ((
this.consumeTimes.
get() %
5) ==
0) {
context.setSuspendCurrentQueueTimeMillis(
3000);
return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
}
return ConsumeOrderlyStatus.SUCCESS;
}
});
consumer.start();
System.out.println(
"Consumer Started.");
}
}
|
虽然提供了 Push 模式,RocketMQ 内部实际上还是 Pull 模式的 MQ,Push 模式的实现应该采用的是长轮询,这点与 Kafka 一样。使用该方式有几个注意的地方,
MessageListenerOrderly
;ConsumeFromWhere
有几个参数,表示从头开始消费,从尾开始消费,还是从某个 TimeStamp 开始消费;context.setAutoCommit(false);
的作用;控制 offset 提交这个特性非常有用,某种程度上扩展一下,就可以当做事务来用了,看代码 ConsumeMessageOrderlyService
的实现,其实并没有那么复杂,在不启用 AutoCommit 的时候,只有返回 COMMIT
才 commit offset;启用 AutoCommit 的时候,返回 COMMIT
、ROLLBACK
(这个比较扯)、SUCCESS
的时候,都 commit offset。
后来发现,commit offset 功能在 Kafka 里面也有提供,使用新的 API,调用
consumer.commitSync
。
再看一个 Push 模式乱序消费 + 消息过滤的例子,消费者的代码如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import java.util.List;
import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.common.message.MessageExt;
public
class Consumer {
public
static
void main(String[] args) throws InterruptedException, MQClientException {
DefaultMQPushConsumer consumer =
new DefaultMQPushConsumer(
"ConsumerGroupNamecc4");
consumer.setNamesrvAddr(
"192.168.232.23:9876");
consumer.subscribe(
"TopicTest1", MessageFilterImpl.
class.getCanonicalName());
consumer.registerMessageListener(
new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List
ConsumeConcurrentlyContext context) {
System.out.println(Thread.currentThread().getName() +
" Receive New Messages: " + msgs);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
consumer.start();
System.out.println(
"Consumer Started.");
}
}
|
这个例子与之前顺序消费不同的地方在于,
MessageListenerConcurrently
;MessageFilterImpl
;消息过滤类 MessageFilterImpl
的代码如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import com.alibaba.rocketmq.common.filter.MessageFilter;
import com.alibaba.rocketmq.common.message.MessageExt;
public
class MessageFilterImpl implements MessageFilter {
@Override
public
boolean
match(MessageExt msg) {
String property = msg.getUserProperty(
"SequenceId");
if (property !=
null) {
int id = Integer.parseInt(property);
if ((id %
3) ==
0 && (id >
10)) {
return
true;
}
}
return
false;
}
}
|
RocketMQ 执行过滤是在 Broker 端,Broker 所在的机器会启动多个 FilterServer 过滤进程;Consumer 启动后,会向 FilterServer 上传一个过滤的 Java 类;Consumer 从 FilterServer 拉消息,FilterServer 将请求转发给 Broker,FilterServer 从 Broker 收到消息后,按照 Consumer 上传的 Java 过滤程序做过滤,过滤完成后返回给 Consumer。这种过滤方法可以节省网络流量,但是增加了 Broker 的负担。可惜我没有实验出来使用过滤的效果,即使是用 github wiki 上的例子8也没成功,不纠结了。RocketMQ 的按 Tag 过滤的功能也是在 Broker 上做的过滤,能用,是个很方便的功能。
还有一种广播消费模式,比较简单,可以去看代码,不再列出。
总之,RocketMQ 提供的功能比较多,比 Kafka 多很多易用的 API。
按之前所说,只有 RocketMQ 的多主多从异步复制是可以生产使用的,因此只在这个场景下测试。另外,消息采用 Push 顺序模式消费。
假设集群采用2主2备的模式,需要启动4个 Broker,配置文件如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
brokerName=broker-a
brokerId=
0
listenPort=
10911
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-a-async
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-a-async/commitlog
brokerRole=ASYNC_MASTER
brokerName=broker-a
brokerId=
1
listenPort=
10921
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-a-async-slave
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-a-async-slave/commitlog
brokerRole=SLAVE
brokerName=broker-b
brokerId=
0
listenPort=
20911
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-b-async
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-b-async/commitlog
brokerRole=ASYNC_MASTER
brokerRole=ASYNC_MASTER
brokerName=broker-b
brokerId=
1
listenPort=
20921
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-b-async-slave
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-b-async-slave/commitlog
brokerRole=SLAVE
|
另外,每个机构共通的配置项如下,
1
2
3
4
5
6
|
brokerClusterName=DefaultCluster
brokerIP1=
192.168.
232.23
namesrvAddr=
192.168.
232.23:
9876
deleteWhen=
04
fileReservedTime=
120
flushDiskType=ASYNC_FLUSH
|
其他设置均采用默认。启动 NameServer 和所有 Broker,并试运行一下 Producer,然后看一下 TestTopic1 当前的情况,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
$ sh mqadmin topicRoute -n
192.168.
232.23
:
9876 -t
TopicTest1
{
"brokerDatas"
:[
{
"brokerAddrs"
:{
0
:"192.168.232.23:20911",
1
:"192.168.232.23:20921"
},
"brokerName"
:"broker-b"
},
{
"brokerAddrs"
:{
0
:"192.168.232.23:10911",
1
:"192.168.232.23:10921"
},
"brokerName"
:"broker-a"
}
],
"filterServerTable"
:{},
"queueDatas"
:[
{
"brokerName"
:"broker-a",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
},
{
"brokerName"
:"broker-b",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
}
]
}
|
可见,TestTopic1 在2个 Broker 上,且每个 Broker 备机也在运行。下面开始主备切换的实验,分别启动 Consumer 和 Producer 进程,消息采用 Pull 顺序模式消费。在消息发送接收过程中,使用 kill -9
停掉 broker-a
的主进程,模拟突然宕机。此时,TestTopic1 的状态如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
$ sh mqadmin topicRoute -n
192.168.
232.23
:
9876 -t
TopicTest1
{
"brokerDatas"
:[
{
"brokerAddrs"
:{
0
:"192.168.232.23:20911",
1
:"192.168.232.23:20921"
},
"brokerName"
:"broker-b"
},
{
"brokerAddrs"
:{
1
:"192.168.232.23:10921"
},
"brokerName"
:"broker-a"
}
],
"filterServerTable"
:{},
"queueDatas"
:[
{
"brokerName"
:"broker-a",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
},
{
"brokerName"
:"broker-b",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
}
]
}
|
broker-a
的节点已经减少为只有1个从节点。然后启动broker-a
的主节点,模拟恢复,再看一下 TestTopic1 的状态,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
$ sh mqadmin topicRoute -n
192.168.
232.23
:
9876 -t
TopicTest1
{
"brokerDatas"
:[
{
"brokerAddrs"
:{
0
:"192.168.232.23:20911",
1
:"192.168.232.23:20921"
},
"brokerName"
:"broker-b"
},
{
"brokerAddrs"
:{
0
:"192.168.232.23:10911",
1
:"192.168.232.23:10921"
},
"brokerName"
:"broker-a"
}
],
"filterServerTable"
:{},
"queueDatas"
:[
{
"brokerName"
:"broker-a",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
},
{
"brokerName"
:"broker-b",
"perm"
:
6,
"readQueueNums"
:
4,
"topicSynFlag"
:
0,
"writeQueueNums"
:
4
}
]
}
|
此时,RocketMQ 已经恢复。
再来看看 Producer 和 Consumer 的日志,先看 Producer 的,如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
......
00578SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F0000000000126F08,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
2],
queueOffset=
141]
00579SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F0000000000126F9F,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
3],
queueOffset=
141]
00580SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000078D47,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
0],
queueOffset=
700]
00581SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000078DDE,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
700]
00582SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000078E75,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
2],
queueOffset=
699]
00583SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000078F0C,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
3],
queueOffset=
699]
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
00588SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000078FA3,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
0],
queueOffset=
701]
00589SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF000000000007903A,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
701]
00590SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000790D1,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
2],
queueOffset=
700]
00591SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000079168,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
3],
queueOffset=
700]
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:
306)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:
289)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:
679)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:
867)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
842)
at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:
836)
at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:
164)
at com.comstar.demo.rocketmq.simple.Producer.main(Producer.java:
61)
00596SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000791FF,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
0],
queueOffset=
702]
00597SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000079296,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
702]
00598SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF000000000007932D,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
2],
queueOffset=
701]
00599SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000793C4,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
3],
queueOffset=
701]
00600SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF000000000007945B,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
0],
queueOffset=
703]
00601SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000794F2,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
703]
00602SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000079589,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
2],
queueOffset=
702]
00603SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000079620,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
3],
queueOffset=
702]
......
01389SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000965BE,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
900]
01390SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000096655,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
2],
queueOffset=
899]
01391SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF00000000000966EC,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
3],
queueOffset=
899]
01392SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F0000000000127036,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
0],
queueOffset=
143]
01393SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F00000000001270CD,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
1],
queueOffset=
141]
01394SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F0000000000127164,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
2],
queueOffset=
142]
01395SendResult [
sendStatus=SEND_OK,
msgId=C0A8E81700002A9F00000000001271FB,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-a,
queueId=
3],
queueOffset=
142]
01396SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF0000000000096783,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
0],
queueOffset=
901]
01397SendResult [
sendStatus=SEND_OK,
msgId=C0A8E817000051AF000000000009681A,
messageQueue=MessageQueue [
topic=TopicTest1,
brokerName=broker-b,
queueId=
1],
queueOffset=
901]
|
日志中显示,在发送完00583条消息之后,开始发生异常 connect to <192.168.232.23:10911> failed
,原因应该是 broker-a
的主节点被 kill 掉。之后,从00596条消息开始,RocketMQ 又恢复正常,原因是 broker-b
已经开始提供服务,承担了所有的工作。然后,又重新启动了 broker-a
主节点,由于该节点的加入,从01392条消息开始,broker-a
又开始恢复工作。实验中可以验证,RocketMQ 所谓的多主多备模式,实际上,备机被弱化到无以复加,在主节点宕机的时候,备机无法接替主机的工作,而只是将尚未发送的数据发送出去,由剩下的主节点接替工作。也就是说,N 主 N 备的 RocketMQ 集群中,总共有 2N 台机器,实际工作的只有 N 台,如果有一台挂了,就只有 N-1 台工作了,机器的利用率太低了。
再来看一下 Consumer 的日志,如下,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
RocketMQ
00551PullResult [
pullStatus=FOUND,
nextBeginOffset=
696,
minOffset=
0,
maxOffset=
696,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
695,
sysFlag=
0,
bornTimestamp=
1469175032446,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175020973,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007859C,
commitLogOffset=
492956,
bodyCRC=
943070764,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
696,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00559PullResult [
pullStatus=FOUND,
nextBeginOffset=
697,
minOffset=
0,
maxOffset=
697,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
696,
sysFlag=
0,
bornTimestamp=
1469175032720,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175021247,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF00000000000787F8,
commitLogOffset=
493560,
bodyCRC=
921540126,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
697,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00567PullResult [
pullStatus=FOUND,
nextBeginOffset=
698,
minOffset=
0,
maxOffset=
698,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
697,
sysFlag=
0,
bornTimestamp=
1469175033005,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175021533,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000078A54,
commitLogOffset=
494164,
bodyCRC=
2054744282,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
698,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00575PullResult [
pullStatus=FOUND,
nextBeginOffset=
699,
minOffset=
0,
maxOffset=
699,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
698,
sysFlag=
0,
bornTimestamp=
1469175033286,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175021814,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000078CB0,
commitLogOffset=
494768,
bodyCRC=
225294519,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
699,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00583PullResult [
pullStatus=FOUND,
nextBeginOffset=
700,
minOffset=
0,
maxOffset=
700,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
699,
sysFlag=
0,
bornTimestamp=
1469175033586,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175022113,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000078F0C,
commitLogOffset=
495372,
bodyCRC=
1670775117,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
700,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00591PullResult [
pullStatus=FOUND,
nextBeginOffset=
701,
minOffset=
0,
maxOffset=
701,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
700,
sysFlag=
0,
bornTimestamp=
1469175037890,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175026418,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000079168,
commitLogOffset=
495976,
bodyCRC=
344150304,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
701,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00599PullResult [
pullStatus=FOUND,
nextBeginOffset=
702,
minOffset=
0,
maxOffset=
702,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
701,
sysFlag=
0,
bornTimestamp=
1469175042200,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175030734,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF00000000000793C4,
commitLogOffset=
496580,
bodyCRC=
442030354,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
702,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00603PullResult [
pullStatus=FOUND,
nextBeginOffset=
703,
minOffset=
0,
maxOffset=
703,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
702,
sysFlag=
0,
bornTimestamp=
1469175042345,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175030872,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000079620,
commitLogOffset=
497184,
bodyCRC=
688469276,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
703,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00607PullResult [
pullStatus=FOUND,
nextBeginOffset=
704,
minOffset=
0,
maxOffset=
704,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
703,
sysFlag=
0,
bornTimestamp=
1469175042481,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031008,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007987C,
commitLogOffset=
497788,
bodyCRC=
778367237,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
704,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00611PullResult [
pullStatus=FOUND,
nextBeginOffset=
705,
minOffset=
0,
maxOffset=
705,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
704,
sysFlag=
0,
bornTimestamp=
1469175042615,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031143,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000079AD8,
commitLogOffset=
498392,
bodyCRC=
1578919281,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
705,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00615PullResult [
pullStatus=FOUND,
nextBeginOffset=
706,
minOffset=
0,
maxOffset=
706,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
705,
sysFlag=
0,
bornTimestamp=
1469175042753,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031280,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000079D34,
commitLogOffset=
498996,
bodyCRC=
1500619112,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
706,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00619PullResult [
pullStatus=FOUND,
nextBeginOffset=
707,
minOffset=
0,
maxOffset=
707,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
706,
sysFlag=
0,
bornTimestamp=
1469175042887,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031414,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF0000000000079F90,
commitLogOffset=
499600,
bodyCRC=
1355279683,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
707,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00623PullResult [
pullStatus=FOUND,
nextBeginOffset=
708,
minOffset=
0,
maxOffset=
708,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
707,
sysFlag=
0,
bornTimestamp=
1469175043021,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031548,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007A1EC,
commitLogOffset=
500204,
bodyCRC=
457136030,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
708,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00627PullResult [
pullStatus=FOUND,
nextBeginOffset=
709,
minOffset=
0,
maxOffset=
709,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
708,
sysFlag=
0,
bornTimestamp=
1469175043154,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031681,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007A448,
commitLogOffset=
500808,
bodyCRC=
475173767,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
709,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00631PullResult [
pullStatus=FOUND,
nextBeginOffset=
710,
minOffset=
0,
maxOffset=
710,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
709,
sysFlag=
0,
bornTimestamp=
1469175043299,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031826,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007A6A4,
commitLogOffset=
501412,
bodyCRC=
1814693875,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
710,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00635PullResult [
pullStatus=FOUND,
nextBeginOffset=
711,
minOffset=
0,
maxOffset=
711,
msgFoundList=
1]MessageExt [
queueId=
3,
storeSize=
151,
queueOffset=
710,
sysFlag=
0,
bornTimestamp=
1469175043435,
bornHost=/
192.168.
234.98:
51987,
storeTimestamp=
1469175031962,
storeHost=/
192.168.
232.23:
20911,
msgId=C0A8E817000051AF000000000007A900,
commitLogOffset=
502016,
bodyCRC=
1799865322,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
711,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessageSync(MQClientAPIImpl.java:
518)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessage(MQClientAPIImpl.java:
433)
at com.alibaba.rocketmq.client.impl.consumer.PullAPIWrapper.pullKernelImpl(PullAPIWrapper.java:
237)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullSyncImpl(DefaultMQPullConsumerImpl.java:
304)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullBlockIfNotFound(DefaultMQPullConsumerImpl.java:
425)
at com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer.pullBlockIfNotFound(DefaultMQPullConsumer.java:
321)
at com.comstar.demo.rocketmq.simple.PullConsumer.main(PullConsumer.java:
56)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessageSync(MQClientAPIImpl.java:
518)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessage(MQClientAPIImpl.java:
433)
at com.alibaba.rocketmq.client.impl.consumer.PullAPIWrapper.pullKernelImpl(PullAPIWrapper.java:
237)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullSyncImpl(DefaultMQPullConsumerImpl.java:
304)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullBlockIfNotFound(DefaultMQPullConsumerImpl.java:
425)
at com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer.pullBlockIfNotFound(DefaultMQPullConsumer.java:
321)
at com.comstar.demo.rocketmq.simple.PullConsumer.main(PullConsumer.java:
56)
com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <
192.168.
232.23:
10911> failed
at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:
641)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessageSync(MQClientAPIImpl.java:
518)
at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.pullMessage(MQClientAPIImpl.java:
433)
at com.alibaba.rocketmq.client.impl.consumer.PullAPIWrapper.pullKernelImpl(PullAPIWrapper.java:
237)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullSyncImpl(DefaultMQPullConsumerImpl.java:
304)
at com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl.pullBlockIfNotFound(DefaultMQPullConsumerImpl.java:
425)
at com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer.pullBlockIfNotFound(DefaultMQPullConsumer.java:
321)
at com.comstar.demo.rocketmq.simple.PullConsumer.main(PullConsumer.java:
56)
Hello MetaQPullResult [
pullStatus=FOUND,
nextBeginOffset=
31,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
148,
queueOffset=
0,
sysFlag=
0,
bornTimestamp=
1468572196808,
bornHost=/
192.168.
234.98:
56837,
storeTimestamp=
1468572191827,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F0000000000011C60,
commitLogOffset=
72800,
bodyCRC=
1751783629,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagA},
body=
11]]
Hello MetaQPullResult [
pullStatus=FOUND,
nextBeginOffset=
31,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
148,
queueOffset=
1,
sysFlag=
0,
bornTimestamp=
1468572196876,
bornHost=/
192.168.
234.98:
56837,
storeTimestamp=
1468572191895,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F0000000000011EB0,
commitLogOffset=
73392,
bodyCRC=
1751783629,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagA},
body=
11]]
Hello MetaQPullResult [
pullStatus=FOUND,
nextBeginOffset=
31,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
148,
queueOffset=
2,
sysFlag=
0,
bornTimestamp=
1468572196903,
bornHost=/
192.168.
234.98:
56837,
storeTimestamp=
1468572191928,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F0000000000012100,
commitLogOffset=
73984,
bodyCRC=
1751783629,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagA},
body=
11]]
RocketMQ
00001PullResult [
pullStatus=FOUND,
nextBeginOffset=
31,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
151,
queueOffset=
3,
sysFlag=
0,
bornTimestamp=
1468572718149,
bornHost=/
192.168.
234.98:
57165,
storeTimestamp=
1468572713175,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F000000000001222B,
commitLogOffset=
74283,
bodyCRC=
1133127810,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagA},
body=
14]]
RocketMQ
00005PullResult [
pullStatus=FOUND,
nextBeginOffset=
31,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
151,
queueOffset=
4,
sysFlag=
0,
bornTimestamp=
1468572718178,
bornHost=/
192.168.
234.98:
57165,
storeTimestamp=
1468572713210,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F0000000000012487,
commitLogOffset=
74887,
bodyCRC=
1156050075,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagA},
body=
14]]
......
[
queueId=
1,
storeSize=
151,
queueOffset=
22,
sysFlag=
0,
bornTimestamp=
1469170324786,
bornHost=/
192.168.
234.98:
49814,
storeTimestamp=
1469170313333,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F000000000010D3AA,
commitLogOffset=
1102762,
bodyCRC=
1707898805,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00477PullResult [
pullStatus=FOUND,
nextBeginOffset=
62,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
storeSize=
151,
queueOffset=
23,
sysFlag=
0,
bornTimestamp=
1469170325237,
bornHost=/
192.168.
234.98:
49814,
storeTimestamp=
1469170313771,
storeHost=/
192.168.
232.23:
10911,
msgId=C0A8E81700002A9F000000000010D606,
commitLogOffset=
1103366,
bodyCRC=
1654764460,
reconsumeTimes=
0,
preparedTransactionOffset=
0,
toString()=Message [
topic=TopicTest1,
flag=
0,
properties={
MIN_OFFSET=
0,
MAX_OFFSET=
205,
KEYS=OrderID188,
WAIT=
true,
TAGS=TagB},
body=
14]]
RocketMQ
00481PullResult [
pullStatus=FOUND,
nextBeginOffset=
62,
minOffset=
0,
maxOffset=
205,
msgFoundList=
31]MessageExt [
queueId=
1,
|