This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-spring.wiki.git
The following commit(s) were added to refs/heads/master by this push:
new 2e95f3b Created 接收消息 (markdown)
2e95f3b is described below
commit 2e95f3bacaf787d76544baf9653423751dbe2a1a
Author: rongtong <[email protected]>
AuthorDate: Wed Dec 25 14:58:59 2019 +0800
Created 接收消息 (markdown)
---
...216\245\346\224\266\346\266\210\346\201\257.md" | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git "a/\346\216\245\346\224\266\346\266\210\346\201\257.md"
"b/\346\216\245\346\224\266\346\266\210\346\201\257.md"
new file mode 100644
index 0000000..c284cd1
--- /dev/null
+++ "b/\346\216\245\346\224\266\346\266\210\346\201\257.md"
@@ -0,0 +1,38 @@
+修改application.properties
+```properties
+## application.properties
+rocketmq.name-server=127.0.0.1:9876
+```
+
+> 注意:
+>
+> 请将上述示例配置中的`127.0.0.1:9876`替换成真实RocketMQ的NameServer地址与端口
+
+编写代码
+```java
+@SpringBootApplication
+public class ConsumerApplication{
+
+ public static void main(String[] args){
+ SpringApplication.run(ConsumerApplication.class, args);
+ }
+
+ @Slf4j
+ @Service
+ @RocketMQMessageListener(topic = "test-topic-1", consumerGroup =
"my-consumer_test-topic-1")
+ public class MyConsumer1 implements RocketMQListener<String>{
+ public void onMessage(String message) {
+ log.info("received message: {}", message);
+ }
+ }
+
+ @Slf4j
+ @Service
+ @RocketMQMessageListener(topic = "test-topic-2", consumerGroup =
"my-consumer_test-topic-2")
+ public class MyConsumer2 implements RocketMQListener<OrderPaidEvent>{
+ public void onMessage(OrderPaidEvent orderPaidEvent) {
+ log.info("received orderPaidEvent: {}", orderPaidEvent);
+ }
+ }
+}
+```
\ No newline at end of file