订单 打印票
This commit is contained in:
parent
c82895d1e3
commit
92d9af40d5
|
|
@ -1,29 +0,0 @@
|
||||||
package com.czg.mq;
|
|
||||||
|
|
||||||
import com.czg.config.RabbitPublisher;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author GYJoker
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
public class RabbitMqController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RabbitPublisher rabbitPublisher;
|
|
||||||
|
|
||||||
@GetMapping("/sendOrderPrintMsg")
|
|
||||||
public String sendOrderPrintMsg(String msg) {
|
|
||||||
rabbitPublisher.sendOrderPrintMsg(msg);
|
|
||||||
return "success";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/sendOrderStockMsg")
|
|
||||||
public String sendOrderStockPrintMsg(String msg) {
|
|
||||||
rabbitPublisher.sendOrderStockMsg(msg);
|
|
||||||
return "success";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
//package com.czg.mq;
|
|
||||||
//
|
|
||||||
//import com.czg.config.RabbitConstants;
|
|
||||||
//import com.rabbitmq.client.Channel;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.amqp.core.Message;
|
|
||||||
//import org.springframework.amqp.rabbit.annotation.*;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.io.IOException;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author GYJoker
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class RabbitmqReceiver {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 消费者监听,绑定队列
|
|
||||||
// * Queue RabbitConfig类的 orderPrintQueue
|
|
||||||
// */
|
|
||||||
// @RabbitListener(
|
|
||||||
// bindings = @QueueBinding(value = @Queue(value = "#{orderPrintQueue.name}", durable = "true",
|
|
||||||
// arguments = {@Argument(name = "x-message-ttl", value = "180000", type = "java.lang.Long")}),
|
|
||||||
// exchange = @Exchange(value = RabbitConstants.Exchange.CASH_EXCHANGE)),
|
|
||||||
// concurrency = "10"
|
|
||||||
// )
|
|
||||||
// @RabbitHandler
|
|
||||||
// public void receiveOrderPrintQueue(Channel channel, String orderId, Message message) throws IOException {
|
|
||||||
// try {
|
|
||||||
// log.info("订单监听 消息体:{},消息内容:{}", message, orderId);
|
|
||||||
// // 手动确认消息,multiple 参数表示是否批量确认
|
|
||||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error(e.getMessage(), e);
|
|
||||||
// // 判断是否需要重新入队
|
|
||||||
// boolean requeue = false;
|
|
||||||
// // 拒绝消息,requeue 为 true 表示将消息重新放回队列
|
|
||||||
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, requeue);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
@ -39,6 +39,9 @@ public class RabbitPublisher {
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
*/
|
*/
|
||||||
public void sendOrderPrintMsg(String orderId) {
|
public void sendOrderPrintMsg(String orderId) {
|
||||||
|
//厨房票
|
||||||
|
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, orderId);
|
||||||
|
//前台票
|
||||||
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
|
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue