商品库存回收消息测试
This commit is contained in:
parent
7a79145dc2
commit
bd12554d42
@ -16,7 +16,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
|
||||
registry
|
||||
.addInterceptor(new LoginInterceptor())
|
||||
//拦截的路径
|
||||
.addPathPatterns("/api/coupon/*/**","/api/coupon_record/v1/*/**")
|
||||
.addPathPatterns("/api/coupon/*/**","/api/coupon_record/*/**")
|
||||
//放行的路径
|
||||
.excludePathPatterns("/api/coupon/*/page_coupon","/api/coupon/*/new_user_coupon");
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class ProductStockMQListener {
|
||||
@RabbitHandler
|
||||
public void releaseProductStock(ProductMessage productMessage, Message message, Channel channel) throws IOException {
|
||||
|
||||
log.info("监听到消息:releaseProductStock", productMessage);
|
||||
log.info("监听到消息:releaseProductStock消息内容:{}", productMessage);
|
||||
long msgTag = message.getMessageProperties().getDeliveryTag();
|
||||
boolean flag = productService.releaseProductStock(productMessage);
|
||||
// 防止同时解锁多任务并发进入
|
||||
@ -51,10 +51,10 @@ public class ProductStockMQListener {
|
||||
}
|
||||
|
||||
|
||||
// @RabbitHandler
|
||||
// public void releaseCouponRecord2(String msg, Message message, Channel channel) throws IOException {
|
||||
// log.info(msg);
|
||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||
//
|
||||
// }
|
||||
@RabbitHandler
|
||||
public void releaseCouponRecord2(String msg, Message message, Channel channel) throws IOException {
|
||||
log.info(msg);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package net.jieyuu.biz;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.jieyuu.ProductApplication;
|
||||
import net.jieyuu.model.CouponRecordMessage;
|
||||
import net.jieyuu.model.ProductMessage;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@ -23,4 +25,12 @@ public class DemoApplicationTests {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCouponRecordRelease() {
|
||||
ProductMessage message = new ProductMessage();
|
||||
message.setOutTradeNo("123456abc");
|
||||
message.setTaskId(1l);
|
||||
rabbitTemplate.convertAndSend("stock.event.exchange", "stock.release.delay.routing.key", message);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user