Skip to content

[mq] rabbit mq #132

Description

@Alice52

concept

  1. Exchange:
    • 如果不指定 Exchange 的话, RabbitMQ 默认使用[AMQP default], 需要将 routing key 等于 queue name 相同
  2. name/type:
    • fanout[效率最好, 不需要 routing key, routing key 如何设置都可以]
    • direct
    • topic[#一个或多个, *一个]
    • headers
  3. Auto Delete:
    • 当最后一个 Binding 到 Exchange 的 Queue 删除之后, 自动删除该 Exchange
  4. Binding:
    • Exchange 和 Queue 之间的连接关系,Exchange 之间也可以 Binding
  5. Queue:
    • 实际物理上存储消息的
  6. Durability: 是否持久化
    • Durable: 是, 即使服务器重启, 这个队列也不会消失
    • Transient: 否
  7. Exclusive:
    • 这个 queue 只能由一个 exchange 监听 restricted to this connection, 使用场景: 顺序消费
  8. Message:
    • properties[有消息优先级、延迟等特性]
    • Body[Payload 消息内容]组成
    • 还有 content_type
    • content_encoding
    • priority
    • correlation_id
    • reply_to
    • expiration
    • message_id 等属性
  9. ack
    • autoACK
    • 手动签收

work flow

rabbitmq

消息

  1. 安全可靠的投递
    • 丢失: 消息落库, confim 对消息状态进行变更 + 消息的延迟投递, 做二次确认, 回调检查
    • 重复: 唯一 ID+指纹码 + Redis 的原子性实现
  2. 消息堆积

消费

  1. 延时消费
  2. 顺序消费
  3. 异步投送
  4. 保证消息不被重复消费[幂等性]

持久化

高可用

retry

事务

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions