heihaozi commented on a change in pull request #307:
URL: https://github.com/apache/rocketmq-spring/pull/307#discussion_r523725486
##########
File path:
rocketmq-spring-boot-samples/rocketmq-consume-demo/src/main/java/org/apache/rocketmq/samples/springboot/ConsumerApplication.java
##########
@@ -17,17 +17,37 @@
package org.apache.rocketmq.samples.springboot;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import javax.annotation.Resource;
+import java.util.List;
+
/**
* ConsumerApplication
*/
@SpringBootApplication
-public class ConsumerApplication {
+public class ConsumerApplication implements CommandLineRunner {
+
+ @Resource
+ private RocketMQTemplate rocketMQTemplate;
+
+ @Resource(name = "extRocketMQTemplate")
+ private RocketMQTemplate extRocketMQTemplate;
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
+
+ @Override
+ public void run(String... args) throws Exception {
+ List<String> messages = rocketMQTemplate.receive(String.class);
+ System.out.printf("receive from rocketMQTemplate, messages=%s %n",
messages);
+
+ messages = extRocketMQTemplate.receive(String.class);
+ System.out.printf("receive from extRocketMQTemplate, messages=%s %n",
messages);
+ }
Review comment:
This is also a good idea.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]