dev-discount
parent
b77e2c82ca
commit
bdb342aefa
File diff suppressed because one or more lines are too long
@ -0,0 +1,26 @@ |
||||
package com.cweb.msg; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.entity.HighOrder; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
||||
import org.apache.rocketmq.spring.core.RocketMQListener; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Component |
||||
@Slf4j |
||||
@RocketMQMessageListener(consumerGroup = "order-cancel-group", topic = "order-topic",selectorExpression = "cancel") |
||||
public class OrderCancelConsumer implements RocketMQListener<HighOrder> { |
||||
@Override |
||||
public void onMessage(HighOrder order) { |
||||
/* System.out.println(JSONObject.toJSONString(order));*/ |
||||
try { |
||||
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "取消订单:" + order.getOrderNo()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
package com.cweb.msg; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.entity.HighOrder; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.poi.ss.formula.functions.T; |
||||
import org.apache.rocketmq.common.message.Message; |
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
||||
import org.apache.rocketmq.spring.core.RocketMQListener; |
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
||||
import org.springframework.messaging.support.MessageBuilder; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
|
||||
@Component |
||||
@Slf4j |
||||
@RocketMQMessageListener(consumerGroup = "order-create-group", topic = "order-topic",selectorExpression = "create") |
||||
public class OrderCreateConsumer implements RocketMQListener<HighOrder> { |
||||
|
||||
@Resource |
||||
private RocketMQTemplate rocketMQTemplate; |
||||
|
||||
@Override |
||||
public void onMessage(HighOrder order) { |
||||
try { |
||||
|
||||
/* System.out.println(JSONObject.toJSONString(order));*/ |
||||
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + " 创建订单:" + order.getOrderNo()); |
||||
|
||||
/* org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); |
||||
|
||||
rocketMQTemplate.syncSend("order-topic:cancel", |
||||
message, |
||||
this.rocketMQTemplate.getProducer().getSendMsgTimeout(), |
||||
4); |
||||
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "发送成功");*/ |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue