Is RabbitMQ capable of “pushing” messages from a queue to a consumer?

后端 未结 4 1050
遥遥无期
遥遥无期 2020-12-17 14:59

With RabbitMQ, is there a way to \"push\" messages from a queue TO a consumer as opposed to having a consumer \"poll and pull\" messages FROM a queue?

This has been

4条回答
  •  旧巷少年郎
    2020-12-17 15:41

    Quoting from the docs here:

    AMQP brokers either deliver messages to consumers subscribed to queues, or consumers fetch/pull messages from queues on demand.

    And from here:

    Storing messages in queues is useless unless applications can consume them. In the AMQP 0-9-1 Model, there are two ways for applications to do this:

    Have messages delivered to them ("push API")
    Fetch messages as needed ("pull API")
    

    With the "push API", applications have to indicate interest in consuming messages from a particular queue. When they do so, we say that they register a consumer or, simply put, subscribe to a queue. It is possible to have more than one consumer per queue or to register an exclusive consumer (excludes all other consumers from the queue while it is consuming).

    Each consumer (subscription) has an identifier called a consumer tag. It can be used to unsubscribe from messages. Consumer tags are just strings.

提交回复
热议问题