您好,欢迎来到99网。
搜索
您的当前位置:首页springboot配置RabbitMQ

springboot配置RabbitMQ

来源:99网

RabbitMQ基本概念

保证消息持久化

消息到MQ的过程中搞丢,MQ自己搞丢,MQ到消费过程中搞丢。
生产者到RabbitMQ:事务机制和Confirm机制,注意:事务机制和 Confirm 机制是互斥的,两者不能共存,会导致 RabbitMQ 报错。
RabbitMQ自身:持久化、集群、普通模式、镜像模式。
RabbitMQ到消费者:关闭RabbitMQ自动ACK

springboot配置

引入依赖

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

application.yml文件

server:
  port: 8001
 
spring:
  application:
    name: myrabbitMqDemo-provider
  #配置rabbitMq 服务器
  rabbitmq:
    host: 192.168.232.134
    port: 5672
    username: guest
    password: guest
    #虚拟host 可以不设置,使用server默认host
    #virtual-host: tmp
 
    #确认消息已发送到交换机(Exchange)  发送确认
    #publisher-confirms: true
    publisher-confirm-type: correlated
    #确认消息已发送到队列(Queue)  发送回调
    publisher-returns: true
    listener:
      simple:
        #程序中设置:rabbitTemplate.setMandatory(true);
        acknowledge-mode: manual
        #并发消费者初始化值
        concurrency: 10
        #并发消费者的最大值
        max-concurrency: 20
        #每个消费者每次监听时可拉取处理的消息数量
        prefetch: 1

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 99spj.com 版权所有 湘ICP备2022005869号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务