Commit 38da5b0a by qiuweili123

调整示例rocketmq

parent d3cbf735
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.secoo.mall</groupId> <groupId>com.secoo.mall</groupId>
<artifactId>matrix-sample-hbase-starter</artifactId> <artifactId>matrix-bigdata-hbase-starter</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.secoo.mall.rocketmq.service; package com.secoo.rocketmq.service;
import com.secoo.mall.rocketmq.bean.User; import com.secoo.rocketmq.bean.User;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class UserService { public class UserService {
public User create(User user){ public User create(User user) {
//实际业务操作 //实际业务操作
return user; return user;
} }
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>matrix-sample-rocketmq-springboot</artifactId> <artifactId>matrix-sample-rocketmq-springboot</artifactId>
<version>1.0.1</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.secoo.mall</groupId> <groupId>com.secoo.mall</groupId>
...@@ -19,6 +21,7 @@ ...@@ -19,6 +21,7 @@
<groupId>com.secoo.mall</groupId> <groupId>com.secoo.mall</groupId>
<artifactId>matrix-sample-rocketmq-biz</artifactId> <artifactId>matrix-sample-rocketmq-biz</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.secoo.rocketmq; package com.secoo.rocketmq;
import com.secoo.mall.common.util.json.FastJsonUtil; import com.secoo.mall.common.util.json.FastJsonUtil;
import com.secoo.mall.rocketmq.bean.User; import com.secoo.rocketmq.bean.User;
import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.messaging.support.MessageBuilder;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -17,7 +18,7 @@ public class RoketMqSampleApplication implements ApplicationRunner { ...@@ -17,7 +18,7 @@ public class RoketMqSampleApplication implements ApplicationRunner {
@Resource @Resource
private RocketMQTemplate template; private RocketMQTemplate template;
@Resource
private String topicName = "roketmq-simple-springboot"; private String topicName = "roketmq-simple-springboot";
public static void main(String[] args) { public static void main(String[] args) {
...@@ -40,8 +41,8 @@ public class RoketMqSampleApplication implements ApplicationRunner { ...@@ -40,8 +41,8 @@ public class RoketMqSampleApplication implements ApplicationRunner {
msg.setMsgId(user.getId().toString()); msg.setMsgId(user.getId().toString());
msg.setBody(FastJsonUtil.toString(user).getBytes()); msg.setBody(FastJsonUtil.toString(user).getBytes());
//2.指定tag,并同步发送消息 //2.指定tag,并同步发送消息
//指定tag为create发送到topic //指定tag为create发送到topic
template.syncSend(topicName + createTagName, msg); template.syncSend( topicName + createTagName, msg);
} }
} }
\ No newline at end of file
package com.secoo.rocketmq.consumer; package com.secoo.rocketmq.consumer;
import com.secoo.mall.rocketmq.bean.User; import com.secoo.rocketmq.bean.User;
import com.secoo.mall.rocketmq.service.UserService; import com.secoo.rocketmq.service.UserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener; import org.apache.rocketmq.spring.core.RocketMQListener;
......
...@@ -8,6 +8,7 @@ import org.apache.rocketmq.common.message.MessageExt; ...@@ -8,6 +8,7 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener; import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener; import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
rocketmq:
name-server: dev01-mq-mall1.secoolocal.com:9876;dev01-mq-mall2.secoolocal.com:9876
producer:
group: simple-group
server:
port: 9090
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment