-
Notifications
You must be signed in to change notification settings - Fork 939
Consume Message
rongtong edited this page Dec 25, 2019
·
3 revisions
Modify application.properties
## application.properties
rocketmq.name-server=127.0.0.1:9876Note:
Maybe you need change
127.0.0.1:9876with your real NameServer address for RocketMQ
@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);
}
}
}More relevant configurations for consuming: