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
最满意答案
这里有很多事要讨论。 首先,关于特定于目标的变量如何工作的心智模型并不十分准确(“一旦发现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.so
或b.so
name实际上是a.so
或b.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 valuea.so
inside the recipe forb.o
only whenb.o
is being created as a prerequisite ofa.so
. Ifb.o
was being created as a prerequisite ofb.so
, thencurrent
would beb.so
. Because your makefile listsa.so
first it will be built first, and becauseb.o
will only be built once (per invocation of make), it may appear that it's always usinga.so
as the value ofcurrent
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 tob.so
ifb.o
is built because it's a prerequisite ofb.so
nota.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
, thencurrent
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 variablecurrent
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 toa.so
orb.so
unless the current target name is actuallya.so
orb.so
. If the target name isb.o
then$@
expands tob.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 witheval
, 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.
相关问答
更多-
根据正在构建的整个项目,CMake add_custom_target(CMake add_custom_target depending on whole project being built)[2022-04-27]
从版本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的先决条件,那 ...
-
在调用shell脚本中的make之前无法设置env变量(Unable to set env variable before calling make in shell script)[2022-03-16]
...当我在第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 ...