In distributed system, declare interface in a common module OR declare 2 same interfaces in both provider and consumer sub-system, which way is more recommended?
I'm working on a distributed system with Apache Dubbo, and I'm confused about the problem above. A 'consumer sub-system'(running in its own JVM) could invoke methods in the 'provider sub-system' as long as the Interface of these methods is registered in Dubbo. So Dubbo service is based on Interface, I have 2 options:
MyDubboService
, in the common module, let's say my-comm
, and add my-comm
as a dependency lib in 'consumer sub-system' and 'provider sub-system'. Then implement and register MyDubboService
(to Dubbo) in 'provider sub-system'.MyDubboService
in 'consumer sub-system' and 'provider sub-system' two times, Then implement and register MyDubboService
(to Dubbo) in 'provider sub-system'.My team adopted option#2 as the strategy, but in my view, option#1 is better because these advantages:
I understand option#1 also has defect, like "opened some useless methods to consumer which consumer may not interested"
So what I want to know is which option is better, or say, how do we decide which way to go, option #1 or #2?
Any comments is welcomed, thanks!