| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public void sendOrderReturn(Long id) { |
| | | log.info("发送消息:{}", id); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(ExchangeConstants.EXCHANGE_DEFAULT, RouteKeyConstants.ROUTE_KEY_DEFAULT, id, correlationData); |
| | | } |
| | | |
| | | public void sendOrderCancelDelayMsg(Long id, Long times) { |
| | | log.info("发送自动取消订单消息:{}, {}", id, times); |
| | | rabbitTemplate.convertAndSend(RabbitQueueEnum.ORDER_CANCEL_DELAY_TTL.getExchange(), RabbitQueueEnum.ORDER_CANCEL_DELAY_TTL.getRoute(), id, new MessagePostProcessor() { |
| | | @Override |
| | | public Message postProcessMessage(Message message) throws AmqpException { |
| | | message.getMessageProperties().setExpiration(String.valueOf(times)); |
| | | return message; |
| | | } |
| | | }); |
| | | } |
| | | } |