mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-06 11:00:13 +08:00
test方法
This commit is contained in:
@@ -3913,7 +3913,17 @@ public class SpringBootTestController {
|
||||
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount())
|
||||
.orderRefundAmount(orderBasicInfo.getRefundAmount())
|
||||
.build();
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
||||
System.out.println(JSON.toJSONString(afterSettleOrderDTO));
|
||||
|
||||
// for (int i = 0; i < 30; i++) {
|
||||
// // try {
|
||||
// // Thread.sleep(5000);
|
||||
// // } catch (InterruptedException e) {
|
||||
// // throw new RuntimeException(e);
|
||||
// // }
|
||||
// afterSettleOrderDTO.setOrderCode(orderCode + "_" + i);
|
||||
// rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jsowell.common.config.mq;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.config.RetryInterceptorBuilder;
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
@@ -28,6 +28,7 @@ import org.springframework.retry.support.RetryTemplate;
|
||||
// #以下是rabbitmqTemplate配置
|
||||
// mandatory: true)
|
||||
// 3---设置重试
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class RabbitConfig {
|
||||
|
||||
@@ -77,7 +78,7 @@ public class RabbitConfig {
|
||||
// 预加载消息数量 -- QOS
|
||||
containerFactory.setPrefetchCount(1);
|
||||
// 应答模式(此处设置为手动)
|
||||
containerFactory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
||||
// containerFactory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
||||
// 消息序列化方式
|
||||
containerFactory.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||
// 设置通知调用链 (这里设置的是重试机制的调用链)
|
||||
@@ -143,7 +144,7 @@ public class RabbitConfig {
|
||||
@Override
|
||||
public <T, E extends Throwable> void onError(RetryContext retryContext, RetryCallback<T, E> retryCallback, Throwable throwable) {
|
||||
// 异常 都会调用
|
||||
System.err.println("-----第{}次调用"+retryContext.getRetryCount());
|
||||
log.info("-----第{}次调用", retryContext.getRetryCount());
|
||||
}
|
||||
});
|
||||
retryTemplate.setBackOffPolicy(backOffPolicyByProperties());
|
||||
|
||||
@@ -36,6 +36,6 @@ public class OrderRabbitListener {
|
||||
// }
|
||||
|
||||
//由于配置设置了手动应答,所以这里要进行一个手动应答。注意:如果设置了自动应答,这里又进行手动应答,会出现double ack,那么程序会报错。
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import lombok.Data;
|
||||
public class TestRabbitMQDTO {
|
||||
private String exchange;
|
||||
private String routingKey;
|
||||
private String data;
|
||||
private Object data;
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
||||
transactionService.doUpdateOrder(dto);
|
||||
|
||||
// 订单退款
|
||||
// refundOrder(orderBasicInfo);
|
||||
refundOrder(orderBasicInfo);
|
||||
|
||||
// 组装after参数
|
||||
AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder()
|
||||
|
||||
Reference in New Issue
Block a user