RabbitMQ

RabbitMQ

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 19:34:49
FAQ Q: 如何确保消息不丢失? Q: mq 的缺点 Q: 如何避免消息重复投递或重复消费? 在消息 生产 时,MQ 内部针对每条生产者发送的消息生成一个 inner-msg-id,作为去重的依据(消息投递失败并重传),避免重复的消息进入队列; 在消息 消费 时,要求消息体中必须要有一个 bizId(对于同一业务全局唯一,如支付 ID、订单 ID、帖子 ID 等)作为去重的依据,避免同一条消息被重复消费 Q: rabbitmq 怎么避免消息丢失? 消息持久化 ACK确认机制 设置集群镜像模式 消息补偿机制 Q: 要保证消息持久化成功的条件有哪些? 参考资料 https://zhuanlan.zhihu.com/p/62087283 https://juejin.im/post/5dfc93a5f265da339b500273#heading-7 来源: https://www.cnblogs.com/yudidi/p/12188722.html

RabbitMQ Consumer always directly shutsdown (C#)

ぐ巨炮叔叔 提交于 2020-01-13 13:54:29
问题 At The moment im learning how to work with the RabbitMQ. Sending works. But Recieving doesn't work. This is my code: var factory = new ConnectionFactory() { HostName = hostName }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: queueName, durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea

rabbitmq 重复ACK导致消息丢失

爷,独闯天下 提交于 2020-01-13 13:28:47
rabbitmq 重复确认导致消息丢失 背景 rabbitmq 在应用场景中,大多采用工作队列 work-queue的模式。 在一个常见的工作队列模式中,消费者 worker 将不断的轮询从队列中拉取最新消息,当队列负载压力增大时允许添加多个worker 进行处理。 然而执行一个任务可能需要相当的时长,这是由业务特性所决定的;如果 worker执行任务过程中出现异常甚至宕机,此时消息便会丢失,这是简单消息队列难以解决的问题。 rabbitmq 采用了消息确认机制来防止此类问题,在该机制中,worker需要向 MQ Server 返回 ACK响应以表示消息已确认处理; 在以下情况下,rabbitmq 会对消息进行重新投递: 1 client 未响应ACK, 主动关闭 Channel; 2 client 未响应ACk, 网络异常断开; 消息的重发机制没有超时限制,只要client 不响应ACK,那么会一直投递; 如果启用了消息持久化机制,那么消息将有进一步的保障。 问题描述及分析 1 客户端为简化应答处理,可以设置自动应答选项,如: boolean autoAck = false; channel.basicConsume(TASK_QUEUE_NAME, autoAck, consumer); 2 如果不启用自动应答,需要应用代码手动进行应答: try { doWork

rabbitmq HA cluster

让人想犯罪 __ 提交于 2020-01-13 13:12:14
问题 I am wanting to setup RabbitMQ as a two (or more) node cluster with HA. Use case: a client producer app (C#.NET) knows that the cluster has two nodes and publishes to the cluster. Various consumer apps (also C#.NET) connect to the cluster and get all messages generated by the producer. So long as at least one node is up and running the producer and consumers will all continue to work without error. Supposing nodes A and B are running and B dies for a while, then gets restarted, then a while

rabbitmq HA cluster

♀尐吖头ヾ 提交于 2020-01-13 13:12:06
问题 I am wanting to setup RabbitMQ as a two (or more) node cluster with HA. Use case: a client producer app (C#.NET) knows that the cluster has two nodes and publishes to the cluster. Various consumer apps (also C#.NET) connect to the cluster and get all messages generated by the producer. So long as at least one node is up and running the producer and consumers will all continue to work without error. Supposing nodes A and B are running and B dies for a while, then gets restarted, then a while

centos中rabbitmq的安装及php支持

做~自己de王妃 提交于 2020-01-13 12:07:09
转自:http://www.phpac.com/741.html 1.安装rabbitmq-c库和codegen配件 wget https://github.com/alanxz/rabbitmq-c/tarball/0.2 tar zxf 0.2 wget https://github.com/rabbitmq/rabbitmq-codegen/tarball/master tar zxf master mv rabbitmq-rabbitmq-codegen-4e97f73/ alanxz-rabbitmq-c-f8f4fc7/codegen (文件夹名不一定,用ls查看) cd alanxz-rabbitmq-c-f8f4fc7 autoreconf -i 如果没有报错,则继续执行 ./configure make && make install 2.安装php RabbitMQ扩展 wget http://pecl.php.net/get/amqp-1.0.4.tgz tar zxf amqp-1.0.4.tgz && cd amqp-1.0.4 /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config –with-amqp (php

Celery configure separate connection for producer and consumer

六眼飞鱼酱① 提交于 2020-01-13 10:55:13
问题 We have an application setup on heroku, which uses celery to run background jobs. The celery app uses RabbitMQ as the broker. We used heroku’s RabbitMQ Bigwig add-on as AMQP message broker. This add-on specifies two separate url one optimized for producer and other optimized for consumer. Also, as per RabbitMQ documentation it is recommended to use separate connections for producer and consumer. Celery documentation does not provide a ways to specify connections separately to producer and

Rabbitmq message arrival time stamp

泄露秘密 提交于 2020-01-13 08:35:47
问题 Is there a way to get the timestamp when a message was placed on the queue, from a consumer. Not when it was published, but when it actually made it to the queue. 回答1: No there's no way to figure this out, unless, as you state yourself you write a plugin for this. There is nothing in the AMQP specification that says that the message must know when it arrived in the queue. There is no need from the AMQP point of view to know this. There are also many cases when the message might pass through

Why shouldn't I use rabbitmq topic exchanges for everything?

跟風遠走 提交于 2020-01-13 06:54:18
问题 It seems like the worker pattern, fanout, and filtered topics can all be implemented with topic exchanges. Why would I ever use a direct or fanout exchange instead? We would like to codify common patterns found in our org in a library that abstracts the infinite flexibility of amqp (naming conventions, defaulting to durable, sending common headers, expirations etc.). Should we leverage the different exchange types or implement all patterns with topics; why? (We have consumers/publishers in

How to aggregate RabbitMq messages into single message by correlation ID

寵の児 提交于 2020-01-13 04:42:08
问题 Let's say that I have a pipeline of commands that need to be executed sequentially and that some of the commands contain multiple operations that should be executed in parallel (same correlation id). And let's assume that I need to know when all parallel operations are executed in order to proceed with execution further in the pipeline. Is it possible to achieve this kind of orchestration with RabbitMQ alone by using exchanges and queues without usage of external data sources like database ?