首页 > 其他分享 >rabbitmq的启动命令和springboot整合使用rabbitmq

rabbitmq的启动命令和springboot整合使用rabbitmq

时间:2023-02-27 10:00:44浏览次数:34  
标签:springboot SUCCESS process rabbitmq 整合 Integer ResponseVo uid


环境:windows
安装erlang和rabbitmq的过程这里不多说,记得两个的版本要对应。

1.启动rabbitmq:

进入sbin目录:

rabbitmq的启动命令和springboot整合使用rabbitmq_erlang

rabbitmq的启动命令和springboot整合使用rabbitmq_erlang_02


其中可能报错:

rabbitmq的启动命令和springboot整合使用rabbitmq_erlang_03


则需要终止已经开始的进程(可能是之前启动过)

tasklist|find /i “erl”

erlsrv.exe 4676 Services 0 716 K

erl.exe 5916 Services 0 21,328 K

erl.exe 29252 Console 1 23,428 K

C:\Users\14172>taskkill /pid “4676” -f
SUCCESS: The process with PID 4676 has been terminated.

C:\Users\14172>taskkill /pid “29252” -f
SUCCESS: The process with PID 29252 has been terminated.

C:\Users\14172>taskkill /pid “5916” -f
SUCCESS: The process with PID 5916 has been terminated.

再次输入

rabbitmq-server.bat start

2.在springboot中使用

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

配置:

spring:

rabbitmq:
addresses: 127.0.0.1
port: 5672
username: guest
password: guest

代码:

public interface IOrderService {

ResponseVo<OrderVo> create(Integer uid, Integer shippingId);

ResponseVo<PageInfo> list(Integer uid, Integer pageNum, Integer pageSize);

ResponseVo<OrderVo> detail(Integer uid, Long orderNo);

ResponseVo cancel(Integer uid, Long orderNo);

void paid(Long orderNo);
}
@Component
@RabbitListener(queues = "payNotify")
@Slf4j
public class PayMsgListener {

@Autowired
private IOrderService orderService;

@RabbitHandler
public void process(String msg) {
log.info("【接收到消息】=> {}", msg);

PayInfo payInfo = new Gson().fromJson(msg, PayInfo.class);
if (payInfo.getPlatformStatus().equals("SUCCESS")) {
//修改订单里的状态
orderService.paid(payInfo.getOrderNo());
}
}
}


标签:springboot,SUCCESS,process,rabbitmq,整合,Integer,ResponseVo,uid
From: https://blog.51cto.com/u_15980129/6087447

相关文章