在SOA的循环依赖 [英] Circular dependency in SOA
问题描述
猜到,这是一个常见的问题,但我会尽力来形容当前的问题。
Guess, it is a common question, but I will try to describe current issue.
我有基本的服务,让命名为'CoreService提供我会说:主要功能:处理DB数据(我们已经在我们的应用程序的集中DB)。还有一些其他的应用中,其中一些有自己的数据库,供本地使用。还有一个简单的'NotificationService。其目的是发送广播消息到不同的用户。
I have base-service, lets name it 'CoreService' that provide I would say "main" functionality: handle data in DB (we have centralized DB in our applications). There is a number of other applications, some of them have own DB for local purposes. And there is one simple 'NotificationService'. Its purpose is to broadcast messages to different subscribers.
通常,这种NotificationService从'ExternalWorld打来电话,通知发送给不同的服务(其中之一是CoreService')
Usually, this NotificationService was called from 'ExternalWorld' and send notifications to different services (among them is 'CoreService').
今天,我看到了必要调用从'CoreService'NotificationService。
Today I see a necessity to call 'NotificationService' from 'CoreService'.
在这里,我担心的是,我介绍一个循环依赖:NotificationService需要知道如何将消息发送到每个服务(包括CoreService'所以他需要知道'CoreService界面,因为他需要引用一个结果CoreService')和'CoreService需要将消息发送到NotificationService(所以他需要引用它太)...循环依赖...
My concern here is that I am introducing a circular dependency: NotificationService needs to know how to send messages to each service (including 'CoreService' so he needs to know about 'CoreService' interface and as a result he needs to reference to 'CoreService') and 'CoreService' needs to send messages to 'NotificationService (so he needs to reference it too)... Circular dependency...
问:我们应该如何构建我们的架构来处理此类问题。
Question: How should we build our architecture to handle such issue?
非常感谢!
推荐答案
当我完成写作的问题,我发现了一些想法:
When I completed writing question I found some idea:
在'NotificationService我需要定义2接口'IMessagesSender'和'IMessagesReceiver。
Inside of 'NotificationService' I need to define 2 interfaces 'IMessagesSender' and 'IMessagesReceiver'.
- 每个用户应该实现'IMessagesReceiver和它的地址应该被写进NotificationService配置文件;
- 每个消息发送者应该消耗描述IMessageSender界面,应该有与NotificationService的地址自己的配置文件记录'WSDL'的文件。
在这种情况下,我们不会删除循环依赖,但它似乎是一个解决方案...
In this case we won't remove circular dependency, but it seems like a solution...
现在,这是我很难说什么是最好的方式ANS是什么这个解决方案的优点和缺点,所以请评论它(和/或建议最好的一个)。
Right now, it is hard for me to say what is the best way ans what are pros and cons of this solution, so please comment it (and/or suggest the better one).
非常感谢!
这篇关于在SOA的循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!