Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Event design and testing #924

Closed
jrobertshawe opened this issue Jan 26, 2019 · 7 comments
Closed

Event design and testing #924

jrobertshawe opened this issue Jan 26, 2019 · 7 comments
Labels

Comments

@jrobertshawe
Copy link

Hi there -
First thanks for a great project that has helped me tremendously and provided me with a great template for my project.

I have a question around events testing with a event driven micro service that does complex calculations
In the customer domain all the processing around capturing and storing the customers details. Once completed and with every update, a payload is sent via an event to the calc service that has it's own database to calculate a premium and this is returned to the customer service via an event payload.
Is this a correct design to use events for a round trip process?
What is the recommendation to test the round trip is successful via function testing using a development service bus

thanks in advance :)
Julian

@mvelosop
Copy link
Collaborator

Hi @jrobertshawe,

Even though this is not related to eShopOnContainers, it's a pretty interesting question 👍

I'll just throw in my two cents, just in case it helps somehow.

If I understood it correctly, you are essentially implementing an asynchronous command based on events.

That adds complexity because the essence of events is they are "fire-and-forget" and, since these are commands and you have to know the result, it's not fire-and-forget, and hence the additional complexity.

Perhaps (but as usual, it depends on the context) a better pattern could be creating a queue of documents to be calculated and then synchronously access the other microservice to get the result.

This way, as a whole, they would be processed asynchronously because they are in a queue, but each command is executed synchronously, so it's pretty easy to get the result.

This might not be so easy in your context, so take this with a grain of salt.

You might want to take a look at this section of the Microservices Guide that goes along with this repo, for it's related to your issue.

Hope this helps.

@mvelosop
Copy link
Collaborator

I forgot to include a link regarding the testing part of your question, you might also want to take a look at this page: https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/test

@jrobertshawe
Copy link
Author

jrobertshawe commented Jan 29, 2019 via email

@mvelosop
Copy link
Collaborator

Hi @jrobertshawe,

The UI doesn't work as an intermediator between any two microservices, it just pushes it's updates to one of them (Ordering, for example) and then waits for the events/messages in the server to notify it back (using SignalR)

The general process flow is like this:

  • A post from the user gets to and API controller that creates a command or publishes and integration event
  • If it's a command it gets handled by a command handler
  • The command handler might publish an integration event
  • When the integration event is handled in another microservice it usually creates a command
  • The command handler in the receiving microservices does the update or whatever it might again publish another integration event and so on.

I suggest you to follow the "trip" that originates from the Checkout action in https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Web/WebMVC/Controllers/OrderController.cs

Hope this helps.

@jrobertshawe
Copy link
Author

jrobertshawe commented Feb 4, 2019 via email

@mvelosop
Copy link
Collaborator

mvelosop commented Feb 4, 2019

Hi Julian, I'm glad this could help!

I'm marking this as a Question for future reference.

Do you think this issue can be considered answered?

@jrobertshawe
Copy link
Author

jrobertshawe commented Feb 4, 2019 via email

@mvelosop mvelosop closed this as completed Feb 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants