rebus - Accepting command and raising events from a service
问题描述
Using Rebus as message bus over RabbitMq message broker for enabling event driven communication between micro services. Using bus.Send(command) service A sends command over a specific queue, to which service B has subscribed. we are using type based routing.
Service B during the workflow of command needs to emit events for change in status (performingA, performedA etc..). One of the handler for an event will be in service B only ( per say it will listen to a specific event and call another api).
To achieve this do I need to have 3 instances of rebus in service B? One for subscribing to command from service A and another for raising events and 3rd to handle the event?
解决方案
do I need to have 3 instances of rebus in service B? One for subscribing to command from service A and another for raising events and 3rd to handle the event?
No you only need one Rebus instance in service B.
One Rebus endpoint (with one input queue) is enough to:
...receive the command (you already know that )
...subscribe to an event (e.g. await bus.Subscribe<YourEvent>();
)
...publish the event (e.g. await bus.Publish(new YourEvent(...);
)
...receive the event (because you subscribed to it, creating a binding from a topic named after your YourEvent
type to service B's input queue.
推荐阅读
- javascript - 条件为真时如何显示和隐藏数据
- c# - 当我添加列时,如何找到受影响的程序。Oracle 和 C#
- typescript - 打字稿接口变量空检查并设置默认值
- node.js - 将 axios 请求 'data' 字段转换为 'body' 么
- google-play-console - 开发人员询问我的密钥库和密码
- c++ - 将类声明与定义分开
- flutter - flutter web : 如何找到 iframeElement 来替换它的 src
- android - Android - 带有 ViewPager 的 MVVM
- php - 我可以在哪里存储,如何在 CakePHP 3.9 中加载 Widget 字符串模板?
- rust - 如何在 Rust 中使用 nix::mount::mount() 替换为 libc::mount()