首页 \ 问答 \ RabbitMQ集群w / .Net客户端(RabbitMQ cluster w/ .Net client)

RabbitMQ集群w / .Net客户端(RabbitMQ cluster w/ .Net client)

我此时已经阅读了很多帖子和博客,我仍然不确定如何正确地集群我的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 -客户端2.4.1-API指南.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


原文:https://stackoverflow.com/questions/6101721
更新时间:2021-12-21 14:12

最满意答案

这里有很多事要讨论。 首先,关于特定于目标的变量如何工作的心智模型并不十分准确(“一旦发现a.so应该构建”,“a.so:current = a.so就会被触发”)。 真正发生的是每个目标进行遭遇会创建一个新的“范围”,该范围在该目标及其所有先决条件被创建时处于活动状态,并且该目标的特定于目标的变量在该范围内有效。 一旦该范围退出(目标完成),那些变量设置就消失了。

在上面的示例中, 只有在创建bo作为a.so的先决条件时, a.so 才会bo的配方中具有值a.so 如果创建bo作为b.so的先决条件,那么current将是b.so 因为你的makefile首先列出了a.so首先会构建它,因为bo只会被构建一次(每次调用make),它可能看起来总是使用a.so作为current的值,但这并不准确。 考虑一下:

$ make all
Current .so is a.so
touch b.o
Current .so is a.so
touch a.so
Current .so is b.so
touch b.so

但是这个:

$ rm -f b.o
$ make b.so
Current .so is b.so
touch b.o
Current .so is b.so
touch b.so

看看current如何设置b.so如果bo是构建的,因为它是b的先决条件而不是a.so

还有这个:

$ rm -f b.o
$ make b.o
Current .so is
touch b.o

这里因为bo不是任何.so的先决条件,所以根本没有设置current

接下来要考虑的是这一行:

%.so : current = $@

这条线被bo “触发”并不是真的。 但是,这会将特定于模式的变量设置为值$@ (注意, 不要扩展$@变量!)。 这意味着每次扩展$(current) ,它将扩展为$@ ,这是当前目标名称,无论其使用的是什么配方。因此除非当前目标,否则不会扩展到a.sob.so name实际上是a.sob.so 如果目标名称是bo$@扩展为bo

如果你想这样做你不能使用像$@这样的变量,你必须使用实际值。 您可以使用eval执行此操作,例如:

sofiles = a b
$(foreach SO,$(sofiles),$(eval $(SO).so: current = $(SO).so))

但是,基于上面的第一条评论,我不确定这是否足以满足您的需求。


There are many things to discuss here. First, your mental model of how target-specific variables works is not quite accurate ("the line a.so: current = a.so gets triggered as soon as make finds out that a.so should be build"). What really happens is that each target make encounters creates a new "scope" which is active while that target and all its prerequisites are being created, and the target-specific variables for that target are in effect inside that scope. Once that scope exits (the target is finished) then those variable settings are gone.

In your example above, current will have the value a.so inside the recipe for b.o only when b.o is being created as a prerequisite of a.so. If b.o was being created as a prerequisite of b.so, then current would be b.so. Because your makefile lists a.so first it will be built first, and because b.o will only be built once (per invocation of make), it may appear that it's always using a.so as the value of current but that's not precisely accurate. Consider this:

$ make all
Current .so is a.so
touch b.o
Current .so is a.so
touch a.so
Current .so is b.so
touch b.so

But also this:

$ rm -f b.o
$ make b.so
Current .so is b.so
touch b.o
Current .so is b.so
touch b.so

See how current is set to b.so if b.o is built because it's a prerequisite of b.so not a.so.

And also this:

$ rm -f b.o
$ make b.o
Current .so is
touch b.o

Here because b.o isn't a prerequisite of any .so, then current is not set at all!

The next thing to think about is this line:

%.so : current = $@

It's not true that this line is "triggered" for b.o. However, this sets the pattern-specific variable current to the value $@ (note, NOT to the expansion of the $@ variable!). This means that each time $(current) is expanded it will expand to $@, which is the current target name, for whatever recipe it's used in. So this won't expand to a.so or b.so unless the current target name is actually a.so or b.so. If the target name is b.o then $@ expands to b.o.

If you want to do this you can't use a variable like $@, you have to use the real value. You can do this with eval, for example:

sofiles = a b
$(foreach SO,$(sofiles),$(eval $(SO).so: current = $(SO).so))

However, based on the first comments above I'm not sure that's sufficient for your needs.

相关问答

更多
  • 从版本2.8开始,CMake不提供包含所有目标列表的变量。 您可以做的最好的方法是使用调用内置add_executable的自定义宏来覆盖内置命令add_library和add_executable ,并跟踪变量中的所有已定义目标。 您甚至可以为自定义宏使用相同的名称。 这样您就不必对所有现有的add_library和add_executable调用进行更改。 如果您覆盖其中的任何一个,则原始的内置命令将以下划线作为前缀: set (_allTargets "") macro(add_library _t ...
  • 你的问题变得非常冗长和复杂,所以我没有全部阅读...因为如果你只是通过一个简单的复制案例问一个你想知道答案的特定目标问题,通常会更好。 我不能说为什么不同的makefile表现不同,但这一行: show_% := DISPLAY_MACRO = $(@:show_%=%) 对我来说似乎真的错了。 这是(a)将变量show_%设置为实际上不在任何地方使用,(b)设置为简单展开的字符串DISPLAY_MACRO =因为在makefile中此时变量$@未设置为任何值。 也许你想要这一行代替: show_% : ...
  • test : override DEBUG := 1不起作用,因为它声明了一个仅在该配方中可见的特定于目标的变量 。 确实存在一个包含在命令行中指定的目标名称的变量: MAKECMDGOALS 。 请注意,如果未在命令行中显式指定,则不包括默认目标。 示例makefile: DEBUG := $(filter test,$(MAKECMDGOALS)) all: @echo all : $(MAKECMDGOALS) : $(DEBUG) : $(if $(DEBUG),1,0) test: ...
  • 我为不同的配置(调试,分段,质量保证,产品)编写了一个REST API端点管理过程。 在这里检查。 你提到的方式也是使用#if和#elseif另一种方式。 #if #elseif #else #endif I have written a REST API Endpoint management process for different configurations (Debug,Staging,QA,Production). Check here. The way you mentioned is a ...
  • 所以,你需要在以下两种情况下运行脚本: src/templates/index.html更改 自上次生成dist/index.html以来ENV环境变量已更改 这个要求的问题是环境变量没有时间戳。 因此,make不知道目标是否是最新的。 通常情况下,类似情况下的解决方案是简单地具有不同的目标,例如dist-development/index.html和dist-production/index.html 。 你甚至可以找到一种方法来使用符号链接或其他东西来有效地将Web应用程序指向正确的最新版本的index ...
  • 我想你可以使用货物配置文件为你指定一个默认的目标三叉戟项目: https ://doc.rust-lang.org/cargo/reference/config.html 在你项目的根目录下创建一个.cargo目录和一个config文件,其中包含以下内容: [build] target = "wasm32-unknown-unknown" I guess you could use a cargo configuration file to specify a default target-tripple ...
  • 如果这可行,我会感到惊讶,因为据我了解,Make进程包含语句, 然后才知道它需要做什么目标。 但我对ClearMake一无所知,我不是真正的专家,所以希望有人证明我错了...... I'd be surprised if this can work, since as I understand it, Make processes include statements before it knows what targets it needs to make. But I know nothing abou ...
  • 这里有很多事要讨论。 首先,关于特定于目标的变量如何工作的心智模型并不十分准确(“一旦发现a.so应该构建”,“a.so:current = a.so就会被触发”)。 真正发生的是每个目标进行遭遇会创建一个新的“范围”,该范围在该目标及其所有先决条件被创建时处于活动状态,并且该目标的特定于目标的变量在该范围内有效。 一旦该范围退出(目标完成),那些变量设置就消失了。 在上面的示例中, 只有在创建bo作为a.so的先决条件时, a.so 才会在bo的配方中具有值a.so 如果创建bo作为b.so的先决条件,那 ...
  • ...当我在第7行注释时,第8行运行良好,为什么不从变量中取出值? 因为本地环境设置是shell 语法的一部分,并且必须明显存在于命令行中,而不是由变量扩展或命令替换产生。 简而言之,在 ${MY_VERSION} make 没有环境设置; 环境设置的语法是NAME=WORD ,并且该命令中没有= 。 因此shell扩展并分词${MY_VERSION}并使用扩展中的第一个单词( VERSION=1.0.0 )作为要运行的命令实用程序的名称。 ...when I comment out line 7, li ...
  • 目标特定变量可能很棘手。 改为使用间接。 Make有很多语法可以减少样板文本。 .SECONDEXPANSION通常很好。 草图: .SECONDEXPANSION: ${DEBUG_OBJ} ${RELEASE_OBJ}: $$(patsubst %.o,%.c,$${@F}) gcc ${copts-${@D}} -c $< -o $@ 在这里我们告诉make ./release/ao取决于ac 。 当make决定构建./release/ao它会扩展shell行。 正如它所做的那样, ${@D ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)