Skip to content

Commit

Permalink
document update, default disable trace
Browse files Browse the repository at this point in the history
  • Loading branch information
pufang committed Nov 16, 2017
1 parent 8f8e5d9 commit 7606b45
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# rocketmq-spring-boot-starter

## spring boot starter for RocketMQ [![Build Status](https://travis-ci.org/maihaoche/rocketmq-spring-boot-starter.svg?branch=master)](https://travis-ci.org/maihaoche/rocketmq-spring-boot-starter) [![Coverage Status](https://coveralls.io/repos/github/maihaoche/rocketmq-spring-boot-starter/badge.svg?branch=master)](https://coveralls.io/github/maihaoche/rocketmq-spring-boot-starter?branch=master)
# spring boot starter for RocketMQ [![Build Status](https://travis-ci.org/maihaoche/rocketmq-spring-boot-starter.svg?branch=master)](https://travis-ci.org/maihaoche/rocketmq-spring-boot-starter) [![Coverage Status](https://coveralls.io/repos/github/maihaoche/rocketmq-spring-boot-starter/badge.svg?branch=master)](https://coveralls.io/github/maihaoche/rocketmq-spring-boot-starter?branch=master)

<p><a href="http://search.maven.org/#search%7Cga%7C1%7Ccom.maihaoche"><img src="https://maven-badges.herokuapp.com/maven-central/com.maihaoche/spring-boot-starter-rocketmq/badge.svg" alt="Maven Central" style="max-width:100%;"></a><a href="https://github.com/maihaoche/rocketmq-spring-boot-starter/releases"><img src="https://camo.githubusercontent.com/795f06dcbec8d5adcfadc1eb7a8ac9c7d5007fce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d646f776e6c6f61642d6f72616e67652e737667" alt="GitHub release" data-canonical-src="https://img.shields.io/badge/release-download-orange.svg" style="max-width:100%;"></a>

首先添加maven依赖:


### 1. 添加maven依赖:

```
<dependency>
Expand All @@ -14,13 +14,19 @@
</dependency>
```

添加配置:
### 2. 添加配置:

```
rocketmq:
name-server-address: 172.21.10.111:9876
# 可选, 如果无需发送消息则忽略该配置
producer-group: local_pufang_producer
# 发送超时配置毫秒数, 可选, 默认3000
send-msg-timeout: 5000
# 追溯消息具体消费情况的开关
#trace-enabled: true
```
### 3. 入口添加注解开启自动装配

在springboot应用主入口添加`@EnableMQConfiguration`注解开启自动装配:

Expand All @@ -31,7 +37,9 @@ class CamaroDemoApplication {
}
```

定义消息体,通过`@MQKey`注解将对应字段设置为消息key,可以在注解中通过`prefix`定义key的前缀:
### 4. 定义消息体

可以通过`@MQKey`注解将消息POJO中的对应字段设置为消息key,通过`prefix`定义key的前缀:

```
data class DemoMessage(
Expand All @@ -41,15 +49,20 @@ data class DemoMessage(
```

创建发送方(详见[wiki](https://github.com/maihaoche/rocketmq-spring-boot-starter/wiki/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5-Provider)):
### 5. 创建发送方

详见[wiki](https://github.com/maihaoche/rocketmq-spring-boot-starter/wiki/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5-Provider)


```
@MQProducer
class DemoProducer : AbstractMQProducer() {
}
```

创建消费方(详见[wiki](https://github.com/maihaoche/rocketmq-spring-boot-starter/wiki/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5-Consumer)):
### 6. 创建消费方

详见[wiki](https://github.com/maihaoche/rocketmq-spring-boot-starter/wiki/%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5-Consumer)

```
@MQConsumer(consumerGroup = "local_pufang_test_consumer", topic = "suclogger")
Expand All @@ -63,7 +76,7 @@ class DemoConsumer : AbstractMQPushConsumer<DemoMessage>() {
}
```

发送消息:
### 7. 发送消息:

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void init() throws Exception {
Assert.notNull(mqProperties.getNameServerAddress(), "name server address must be defined");
producer = new DefaultMQProducer(mqProperties.getProducerGroup());
producer.setNamesrvAddr(mqProperties.getNameServerAddress());
producer.setSendMsgTimeout(mqProperties.getSendMsgTimeout());
producer.start();
}
// register default mq producer to spring context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public class MQProperties {
*/
private String producerGroup;
/**
* switch of trace message consumer: send message consumer info to topic: rmq_sys_TRACE_DATA
* config send message timeout
*/
private Boolean traceEnabled = Boolean.TRUE;
private Integer sendMsgTimeout = 3000;
/**
* switch of trace message consumer: send message consumer info to topic: MQ_TRACE_DATA
*/
private Boolean traceEnabled = Boolean.FALSE;
}

0 comments on commit 7606b45

Please sign in to comment.