延迟发送订阅消息

This commit is contained in:
谭凯凯
2024-10-21 10:42:08 +08:00
committed by Tankaikai
parent 8aa6b1e56b
commit 7425f0a4d5
2 changed files with 19 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
}
}
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson, Integer waitTime) {
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson, Integer waitTime) {
ThreadUtil.execAsync(() -> {
if (waitTime != null) {
ThreadUtil.sleep(waitTime, TimeUnit.SECONDS);
@@ -47,7 +47,11 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true, null);
}
public void printTicket(String orderId){
public <T> void sendOrderCollectMsg(T data, int waitTime) {
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true, waitTime);
}
public void printTicket(String orderId) {
sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false, null);
}
@@ -91,7 +95,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
printDTO.setCurrentUserId(SecurityUtils.getCurrentUserId());
printDTO.setCurrentUserName(SecurityUtils.getCurrentUsername());
printDTO.setCurrentUserNickName(SecurityUtils.getCurrentUserNickName());
}catch (Exception e){
} catch (Exception e) {
log.error("获取当前用户信息失败", e);
}
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印", true, null);
@@ -106,12 +110,12 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
}
public void buildCurrentUserInfo(JSONObject jsonObject){
public void buildCurrentUserInfo(JSONObject jsonObject) {
try {
jsonObject.put("currentUserId", SecurityUtils.getCurrentUserId());
jsonObject.put("currentUserName", SecurityUtils.getCurrentUsername());
jsonObject.put("currentUserNickName", SecurityUtils.getCurrentUserNickName());
}catch (Exception e){
} catch (Exception e) {
log.error("获取当前用户信息失败", e);
}
}