Microservice Architecture dependency

六月ゝ 毕业季﹏ 提交于 2019-12-08 11:15:34

Use Point to Point messaging model and only one consumer will receive a mesage. In pub/sub model all subscribers will be notified.
Example with ActiveMQ.

You can still use pub/sub models but you need to set the multiple instances so that only one would get a message. the specific depends on the pub/sub mechanism

for instance in AMQP systems (like RabbitMQ) you'd publish the events on an exchange. the consumer service would bing a queue to that exchange and all the instances of the same service would read from the same queue (so only one would handle any given message)

Another example is Kafka - in Kafka all the instances of the same service would use the same consumer group - so, again, only one instance of each subscribing service would get the message

Other pub/sub systems would have similar solutions.

Point to point to specific instances is not a great solution as it would couple the instances of the different services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!