I just spent few days to researching Saga pattern framework. I feel so confused after reading some article from IBM and Baeldung. You may can give a look on them here
Saga-pattern-microservices
Use-saga-to-solve-distributed-transaction-management-problems
In the article, it said we can use Eventuate Tram Saga in Choreography Pattern.
But The Eventuate Tram said itself Saga orchestration framework. Could any one help me to explain this
Eventuate Tram Sagas implements orchestration saga pattern.
See:
https://eventuate.io/docs/manual/eventuate-tram/latest/getting-started-eventuate-tram-sagas.html
https://github.com/eventuate-tram/eventuate-tram-sagas#eventuate-tram-sagas
Related
At the moment I'm learning about important OOP design patterns and are currently studying the differences between the Observer and the PubSub pattern and how to implement them in Python.
For that reason, I'm asked to implement some easy notification service for a SmartHome with the help of the Observer Pattern. Thereby, the notification service should send notification messages when the house is empty and e.g. the light is still turned on.
Now in a subsequent task I'm asked to argue why the observer pattern is superior to the PubSub pattern in the above example. At the moment I am a little unsure how to answer this question, because I would have considered the PubSub pattern for the above example to be more suitable. However, despite all that I've come to an argument where the Observer pattern might be superior to the PubSub pattern.
PubSub pattern relies on a many-to-many communication.
Confidentiality and authenticity of messages is strongly coupled to the security of the broker that mediates all dataflows.
Publishers and subscribers can easily connect to a broker and exchange data via specific topics which is also true for an attacker (many-to-many communication).
Passive attackers outside the publish/subscribe network can eavesdrop the communication and try to discover content of events and subscriptions.
Due to the above "weaknesses", this would mean that an attacker could potentially monitor if any of the house owners is currently at home to commit burglary if the PubSub pattern is not implemented carefully. However, from my point of view the Subject in the Observer pattern could establish a one-to-one communication on calling the "update" method and establish a secure channel to maintain Confidentiality and Integrity of the sent state change notification.
At the moment, I'm not quite sure about the correctness of my argumentation and would like to ask if anyone could give me a hint to answer this question.
Thank you in advance for your help.
Best regards,
RatbaldMeyer
I am very new on RabbitMQ World and Microservices Architecture. I've watched some tutorials on youtube how to use rabbitMQ but there are some questions I would like to ask.
1.) If the client post the data to my api controller and my api controller publish the data into queue, what is the proper way to respond the post request while the data is being processed on rabbitMQ? Because from the tutorial, It just returns "Ok (Http Code 200)" even though the data is not still completed yet.
2.) Can consumer subscribe more than 1 queue? If yes, is there any configuration sample on startup.cs?
3.) Is there any sample using rabbitMQ on .NetCore for "Real World" cases? Please let me know.
Thanks
It's perfectly okey to return 200. That's just one of many tradeoffs for microservices architecture. E.g. from the performance perspective, it's efficient that you can return early with 200 and propagate all the changes asynchronously through the rest of the distributed system. On the other hand, it adds another type of complexity that you need to embrace - Eventual Consistency. This concept kind of describes what you asked about. Let say your client received 200, but if it immediately calls another microservice the client may not see changes introduced by the previous request, because there is a probability that the changes haven't propagated yet. You need to decide whether it's acceptable in your project or not. If not maybe you should redesign how you split your business domain into microservices, trying to group transactionally close to each other entities together in order to mitigate such problems. If you can't really tolerate Eventual Consistency maybe you should give up on microservices for the particular project.
Yes it can, you could for example create an implementation of IHostedService for each queue listening for messages and run them in parallel with your asp net core app by registering them in the starutp.cs
You'll find this in the repository from the below's links. They use RabbitMQ. Although, there's a bit of abstraction which can make it harder to grasp, it's a great implementation with a bonus of being documented in the free ebook.
https://github.com/dotnet-architecture/eShopOnContainers/ - I can't stress enough how this repository helped me with understanding microservices. There's also a free ebook from Microsoft docs about this repo: https://learn.microsoft.com/en-us/dotnet/architecture/microservices/ . They tackle concepts such as Eventual Consistency and asynchronous communication. It's exactly what you look for.
I am reading through nestjs docs and there seems to be no way to use anything else then built in eventbus. Now let's say my cqrs event wants to communicate with microservices with rabbitmq. So 2 questions:
Is it possible to dispatch event that will send queue to external eventbus?
Is it okey from ddd point of view? Where should I dispatch it then? Dispatch from domain layer? And then parties (microservices) that are interested can listen and write to their own db parts of it or whatever.
And if you can please explain it on human level, I am new to ddd with cqrs. And sorry if it's frequently asked question but it's also related to nestjs so I need some clarifications.
Thanks 😊
Integration events should be used to notify external services. A good practice is to keep the external event bus (integration bus) independent from any micro service. And regarding the 2 questions:
It should be possible to send events to external bus with nestjs. Ex: write a domain event handler that create an integration event and dispatch it. You can create a new IntegrationBus interface and implement it in any technology that fits.
It is definitely OK from DDD point of view. Context mapping (how different contexts share data) is part of the strategic patterns of DDD. Usually the integration events are published in the application layer and in some case it can be more convinient to do it in the infrastructure layer.
Here are few articles with more details about domain and integration events:
https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation
https://devblogs.microsoft.com/cesardelatorre/domain-events-vs-integration-events-in-domain-driven-design-and-microservices-architectures/
I am using Nservicebus sagadata for adding messages to MSMQ and I am new to it.
I have a situation where I have to check if there is any active Saga with a saga data. If there is one then I will read my object ID stored in SagaData.
So is there a way to read or check i there is a SagaData created? Does StuctureMap.ObjectFactory.Container is of any help?
Thanks in advance
Haris
I think the answers you are looking for are documented here. You can also find samples of a saga in the sample applications when you download NServiceBus. HTH
I've read about nservicebus countless times on the net, but still don't get what a service bus is.
All I think is it is a way for very disparate systems to talk to each other? In which case, I don't see why it is any better than WCF?
I've seen the thread on here about what a service bus is but it still hasn't clicked.
Thanks
Assuming that you have read these pages http://particular.net/nservicebus and http://docs.particular.net/nservicebus/architecture/nservicebus-and-wcf you'll find that NServiceBus makes communicating with services much easier.
It wraps WCF by taking care of the poisoned and transactional elements of messaging as well as offering out of the box Pub / Sub style messaging. Benefits that NServiceBus will take care of include:
Long-running stateful processes Using WF on top
On-premise messaging
Client can send messages if server is offline
Poison message detection and dispatching
Poison messages re-processing
Subscriptions persist after restart
Polymorphic message dispatch
Polymorphic message routing
Message-driven unit testing