英文:
RabbitMQ publish and consume same queue in simultaneously
问题
我有一个RabbitMQ消息队列,我想要从Web服务调用ServiceA发布多个消息到队列中。与此同时,还有另一个名为ServiceB的Web服务,它被实现用于以10秒的时间间隔消费来自RabbitMQ同一队列的消息。使用RabbitMQ队列的实现是否支持这种用例?
RabbitMQ是否支持在同时(同时)由发布者和消费者访问同一队列?
英文:
I have a RabbitMQ message queue and I want to publish multiple messages to the queue from a web service call ServiceA. Meantime, there is an another web service called ServiceB which is implemented for consuming the messages from the RabbitMQ same queue in an interval of 10 seconds time period. Is this use case possible with the implementation of the RabbitMQ queues?
Does RabbitMQ support to access the same queue by the publisher and consumer at the same time (simultaneously)?
答案1
得分: 3
> ServiceB 是用于以 10 秒的时间间隔从 RabbitMQ 同一队列中消费消息的实现。
> 通过 RabbitMQ 实现这一点有点奇怪。在 RabbitMQ 中,消费者通道将立即接收消息,除非它的未确认消息达到预取限制。我建议在 RabbitMQ 消费者和 ServiceB 之间添加一个缓冲缓存(每 10 秒刷新一次)。
> RabbitMQ 是否支持发布者和消费者同时访问相同的队列?
在 RabbitMQ 中,发布者不能直接访问队列,你只能将消息发布到交换机,RabbitMQ 守护程序将根据交换机绑定规则路由消息。换句话说,发布者和消费者可以独立并同时工作。
英文:
> ServiceB which is implemented for consuming the messages from the RabbitMQ same queue in an interval of 10 seconds time period.
It's a little bit strange to implement this by RabbitMQ. In RabbitMQ, consumer channel will receive message immediately unless its unAck messages reach the prefetch limit. I recommend to add a Buffer Cache (flush every 10 seconds) between RabbitMQ consumer and ServiceB.
> Does RabbitMQ support to access the same queue by the publisher and consumer at the same time (simultaneously)?
In RabbitMQ, publisher can't access queue directly, you can only publish message to exchange, RabbitMQ Daemon will route message by the exchange binding rule. In other words, publisher and consumer can work independently and simultaneously.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论