带 .Net 客户端的 RabbitMQ 集群

发布于 2024-11-09 06:25:24 字数 1052 浏览 5 评论 0原文

此时我已经阅读了很多帖子和博客,但我仍然不确定如何正确集群我的 2 个 RabbitMQ 节点。

我已阅读 RabbitMQ 集群指南: http://www.rabbitmq.com/clustering.html

我在 API 指南中发现了一个神秘的 ClusterId,但没有解释如何获取该 Id:http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.4.1/rabbitmq-dotnet-client-2.4.1-api-guide.pdf

在 StackOverflow 帖子中了解到基本上我需要我的客户了解集群中的每个节点以及故障转移场景的代码:rabbitmq HA 集群

现在...如果可能的话,我想要的行为是更加透明的。我可能会在客户端上使用该“ClusterId”来让消费者集群感知,然后希望库知道随机连接到任一节点以获取消息。

当然,我知道一条消息一次只能在一台服务器上,所以我希望 DotNet 客户端库能够提供一些循环魔法来处理故障转移情况。

从发布者的角度来看,我也希望交换能够循环将消息分发到集群中的各个节点。交换机还可以感知集群并妥善处理故障转移情况。

现在根据我的阅读,它并不完全像那样工作......除非我错过了一些东西。 如果我的知识是最新的并且我必须对所有集群感知业务进行编码,那么...为什么 RabbitMQ 首先具有集群功能?它是如何使用的?

有没有一种方法可以让 RabbitMQ 产生这种行为,而无需编写那么多代码?

谢谢

I've read many posts and blogs at this point and I'm still not sure about how to cluster correctly my 2 RabbitMQ nodes.

I've read the RabbitMQ clustering guide: http://www.rabbitmq.com/clustering.html

I found out about a mysterious ClusterId in the API guide, with no explanation on how to get that Id in the first place: http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.4.1/rabbitmq-dotnet-client-2.4.1-api-guide.pdf

Learned in that StackOverflow post that basically I'd need my clients to be aware of each node in the cluster and code for failover scenario: rabbitmq HA cluster

Now... The behavior I'd like to have is something a little more transparent if possible. Where I would potentially use that "ClusterId" on the client to make the consumer cluster aware and then hopefully the library knows to randomly connect to either node to grab messages.

Granted I know a message can only be on one server at a time, so I'm hoping for some round robin magic from the DotNet client library that would also handle fail over situations.

What I was hoping also from a publisher perspective is that the exchange would round robin distribute messages to the various nodes in the cluster. The exchange would also be cluster aware and handle fail over situations gracefully.

Now based on my readings it doesn't quite work like that... unless I missed something.
If my knowledge is up to date and I have to code all that cluster aware business, then... why does RabbitMQ have a cluster feature in the first place? How is it used?

Is there a way to have that kind of behavior out of RabbitMQ without coding that much?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞清仓 2024-11-16 06:25:24

我使用 HAProxy 在rabbitmq的集群节点之间进行故障转移和负载平衡,也在.net客户端上,当节点发生故障时,您需要手动重新连接客户端。

以下是两个节点集群的 HAProxy 配置,节点在 15672 和 25672 端口上运行。
客户端连接到 5672 端口。

global
 daemon
 log 127.0.0.1 alert
 log 127.0.0.1 alert debug

defaults
 log global
 mode http
 option  dontlognull
 option  redispatch
 retries    3
 contimeout 5000
 clitimeout 50000
 srvtimeout 50000

listen rabbitmq 0.0.0.0:5672
  mode tcp
  balance roundrobin
  option  tcpka

server rabbit01 127.0.0.1:25672 check inter 5000 downinter 500

server rabbit02 127.0.0.1:15672 check inter 5000 backup

感谢这篇博客文章 http://www.joshdevins .net/2010/04/16/rabbitmq-ha-testing-with-haproxy/

I'm using HAProxy for failover and load balancing between cluster nodes for rabbitmq, also on .net client side on exception when node fails you need to manually reconnect the client.

Here is the HAProxy configuration for two node cluster, nodes are running on 15672 and 25672 ports.
Clients connect on 5672 port.

global
 daemon
 log 127.0.0.1 alert
 log 127.0.0.1 alert debug

defaults
 log global
 mode http
 option  dontlognull
 option  redispatch
 retries    3
 contimeout 5000
 clitimeout 50000
 srvtimeout 50000

listen rabbitmq 0.0.0.0:5672
  mode tcp
  balance roundrobin
  option  tcpka

server rabbit01 127.0.0.1:25672 check inter 5000 downinter 500

server rabbit02 127.0.0.1:15672 check inter 5000 backup

cudos to this blog post http://www.joshdevins.net/2010/04/16/rabbitmq-ha-testing-with-haproxy/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文