事件驱动的架构......无限循环 [英] Event driven architecture...infinite loop

查看:252
本文介绍了事件驱动的架构......无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个事件驱动的架构,其中A正在等待来自B中的变化和B正在等待从C的变化和C正在等待来自A的变化,形成了一个循环。

I have an event driven architecture where A is waiting for a change from B and B is waiting for a change from C and C is waiting for a change from A, forming a cycle.

现在,如果B电平变化,那么A触发一个事件到C,这激发到B,它将触发到A,它会调用到C ......循环往复。

Now, if B changes, then A fires an event to C, which fires to B, which fires to A, which fires to C...ad infinitum.

我可以改变我的计划,现在不包含这个周期,但我担心我可能把自己逼到墙角在以后的时间,我不能。一个人如何保持这样的事情从设计基于事件的系统时,发生了什么?

I can change my program right now to not contain this cycle, but I am concerned I may put myself into a corner at a later time where I cannot. How does one keep such things from happening when designing event based systems?

推荐答案

循环依赖是非常糟糕的。我只好到您的文章写在A,B和C的条款之前就对我有意义。我想你应该摆脱它。如果你把自己在一个角落里,它可能比你可以运行与循环依赖的问题,更好的一大堆。

Cyclic dependencies are really bad. I had to write down your post in terms of A, B, and C before it even made sense to me. I think you should get rid of it. If you're putting yourself in a corner, it's probably a whole lot better than the problems you can run into with cyclic dependencies.

您可以绝对避免这种情况了。 A,B和C是真正紧密耦合。我认为你需要重新考虑自己的责任。也许有那会占用大量的设计应力的走了常用的D元素。

You can definitely avoid this, too. A, B, and C are really tightly coupled. I think you need to rethink their responsibilities. Perhaps there's a common D element that'll take a lot of your design-stress away.

别的东西,想到的是建筑分层。如果你能层A对B,和任何人说话到B要求的通信要经过上下图层,可以给自己一个轻松的时间。同样,我不知道很多关于你的问题,所以这些都只是广泛的建议。

Something else that comes to mind is architectural Layering. If you can layer A over B, and require communication by anyone speaking to B to go through A and down the layers, you might give yourself an easier time. Again, I don't know much about your problem, so these are just broad suggestions.

最后一个选项,我最不喜欢的,就是要通过这三个组件之间的消息。因为每个被访问,要求每个组件添加到它已看到的消息的消息。然后下一个组件来获得消息有关于谁的看到它的信息。有点像一个标志了表。但同样,最不喜欢的。尝试别的东西第一。

One final option, and my least favorite, is to pass a message between each of the three components. As each is visited, require that each component add to the message that it has seen the message. Then the next component to get the message has information about who's seen it. Kind of like a sign up sheet. But again, least favorite. Try something else first.

祝你好运!

这篇关于事件驱动的架构......无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆