Closed ljh205sy closed 4 years ago
如果说积分汇总和积分明细在入库时报错了new IllegalArgumentException,那么消费者从mq消息队列中取出消息,这个时候消息是被消费了的。 是需要修改t_event_pub中的状态然后重新发送消息到mq队列?
@Override public void handle(EventSubscriber subscriber) { Preconditions.checkNotNull(subscriber); Preconditions.checkNotNull(subscriber.getId()); try { if (Objects.equal(BUSINESS_TYPE, subscriber.getBusinessType())) { // 这里取巧,将生产者的报文特地写成PointFlow的格式 final PointFlow request = Jacksons.getMapper().readValue(subscriber.getPayload(), PointFlow.class); // 简单地增加流水,为了简便就没有模拟任何业务上的校验 pointService.persistFlow(request); // 增加总数 pointService.increasePoint(request.getPoint(), request.getUserId()); getMapper().updateEventStatusByPrimaryKeyInCasMode(subscriber.getId(), EventStatus.NEW, EventStatus.DONE); } else { if (successor != null) { successor.handle(subscriber); } }
} catch (IOException e) { throw new IllegalArgumentException("读取JSON报文至实体时发生异常. payload: " + subscriber.getPayload() + ", entity: PointFlow.class"); } }
你好,最好先列出具体的异常,另外本项目回归主题rest-tcc,相关模块已全部重写,精简无关组件,并详细补充tcc实现细则,感谢关注,有问题可re-open或继续在GitHub Issue中交流!
如果说积分汇总和积分明细在入库时报错了new IllegalArgumentException,那么消费者从mq消息队列中取出消息,这个时候消息是被消费了的。 是需要修改t_event_pub中的状态然后重新发送消息到mq队列?
@Override public void handle(EventSubscriber subscriber) { Preconditions.checkNotNull(subscriber); Preconditions.checkNotNull(subscriber.getId()); try { if (Objects.equal(BUSINESS_TYPE, subscriber.getBusinessType())) { // 这里取巧,将生产者的报文特地写成PointFlow的格式 final PointFlow request = Jacksons.getMapper().readValue(subscriber.getPayload(), PointFlow.class); // 简单地增加流水,为了简便就没有模拟任何业务上的校验 pointService.persistFlow(request); // 增加总数 pointService.increasePoint(request.getPoint(), request.getUserId()); getMapper().updateEventStatusByPrimaryKeyInCasMode(subscriber.getId(), EventStatus.NEW, EventStatus.DONE); } else { if (successor != null) { successor.handle(subscriber); } }