I am working on an MVVM WPF application. I am trying to place an order on a web based API.
My current way of doing it is to have a singleton that does the job of placing the order. It returns a success of failure boolean to the calling code. The calling code acts accordingly.
I am now looking to change to a message bus/event driven order placement system. I want to put an order in my local database, then raise a message that a new order is placed. The singleton would then pick up the message and places the order rather than other code calling the singleton directly.
My question then becomes. How does code that needs to place an order know of failure/success of getting the message to the API?
It seems I have two options.
a) Raise another message which the calling code responds too. (Seems godawful messy)
b) Make the calling code loop until the order status has changed in the database. Then carry on….
I was wondering what you guys do in situations like this? Is there a better way to do this? what is standard best practice for this sort of thing?
Thank you kindly for spending your time