简体   繁体   中英

update publisher order status after receiving event via pub sub pattern

I have an order service that publishes an order status changed event to multiple services with rabbitmq (masstransit). These subscribers are smart enough to know if they can handle the order or not(the name of the service is in the event).

I use the pub sub pattern instead of the command pattern so that i can add new subscribers as the application grows without needing to change the business logic in the publisher.

The problem is that i would like to send an update back to the publisher after one of the subscribers has accepted the order or finished it.

I suspect there are two ways for handling this

  1. send command to the publisher to update the order status
  2. publish event

My questions is which one is de preferred way of doing this? And if it is the second option then where should this event live(in the publisher.contracts library)? or should the publisher.contracts only have events that it publishes itself.

I typically would go with the second option since it gives flexibility but it's probably more so a business requirement so it depends. On where the contract will live, since it's a multiple service probably best to create a separate library for your contract. This way you don't reference the entire project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM