rabbitmq的启动命令和springboot整合使用rabbitmq
生活随笔
收集整理的這篇文章主要介紹了
rabbitmq的启动命令和springboot整合使用rabbitmq
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
環(huán)境:windows
安裝erlang和rabbitmq的過程這里不多說,記得兩個的版本要對應(yīng)。
1.啟動rabbitmq:
進(jìn)入sbin目錄:
其中可能報(bào)錯:
則需要終止已經(jīng)開始的進(jìn)程(可能是之前啟動過)
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 start2.在springboot中使用
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId> </dependency>配置:
spring:rabbitmq:addresses: 127.0.0.1port: 5672username: guestpassword: 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 {@Autowiredprivate IOrderService orderService;@RabbitHandlerpublic void process(String msg) {log.info("【接收到消息】=> {}", msg);PayInfo payInfo = new Gson().fromJson(msg, PayInfo.class);if (payInfo.getPlatformStatus().equals("SUCCESS")) {//修改訂單里的狀態(tài)orderService.paid(payInfo.getOrderNo());}} }總結(jié)
以上是生活随笔為你收集整理的rabbitmq的启动命令和springboot整合使用rabbitmq的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【操作系统】进程间通信的五种方式
- 下一篇: 【转载】一文彻底拿下Java异常